Fix gcc trunk warnings

pull/746/head
Michael 5 years ago
parent 4763888d2c
commit f9e9227e19
No known key found for this signature in database
GPG Key ID: 2D51757B47E2434C

@ -70,6 +70,9 @@ endif(WIN32)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND SHADOW) if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND SHADOW)
message( FATAL_ERROR "shadow-framework is Linux only" ) message( FATAL_ERROR "shadow-framework is Linux only" )

@ -416,7 +416,7 @@ namespace abyss
bool bool
JSONRPC::RunAsync(llarp_ev_loop_ptr loop, const std::string& remote) JSONRPC::RunAsync(llarp_ev_loop_ptr loop, const std::string& remote)
{ {
strncpy(m_connect.remote, remote.c_str(), sizeof(m_connect.remote)); strncpy(m_connect.remote, remote.c_str(), sizeof(m_connect.remote) - 1);
// TODO: ipv6 // TODO: ipv6
m_connect.connected = &JSONRPC::OnConnected; m_connect.connected = &JSONRPC::OnConnected;
m_connect.error = &JSONRPC::OnConnectFail; m_connect.error = &JSONRPC::OnConnectFail;

@ -83,10 +83,9 @@ struct UTPSocketKey
uint32 recv_id; // "conn_seed", "conn_id" uint32 recv_id; // "conn_seed", "conn_id"
UTPSocketKey(const PackedSockAddr &_addr, uint32 _recv_id) UTPSocketKey(const PackedSockAddr &_addr, uint32 _recv_id)
: addr(_addr)
, recv_id(_recv_id)
{ {
memset(this, 0, sizeof(*this));
addr = _addr;
recv_id = _recv_id;
} }
bool bool

@ -16,12 +16,12 @@ namespace llarp
{ {
} }
explicit Key_t(const Data& val) : AlignedBuffer< SIZE >(val) explicit Key_t(const Data& data) : AlignedBuffer< SIZE >(data)
{ {
} }
explicit Key_t(const AlignedBuffer< SIZE >& val) explicit Key_t(const AlignedBuffer< SIZE >& data)
: AlignedBuffer< SIZE >(val) : AlignedBuffer< SIZE >(data)
{ {
} }

@ -13,9 +13,9 @@ namespace llarp
namespace dht namespace dht
{ {
LocalRouterLookup::LocalRouterLookup(const PathID_t &path, uint64_t txid, LocalRouterLookup::LocalRouterLookup(const PathID_t &path, uint64_t txid,
const RouterID &target, const RouterID &_target,
AbstractContext *ctx) AbstractContext *ctx)
: RecursiveRouterLookup(TXOwner{ctx->OurKey(), txid}, target, ctx, : RecursiveRouterLookup(TXOwner{ctx->OurKey(), txid}, _target, ctx,
nullptr) nullptr)
, localPath(path) , localPath(path)
{ {

@ -11,9 +11,9 @@ namespace llarp
namespace dht namespace dht
{ {
LocalTagLookup::LocalTagLookup(const PathID_t &path, uint64_t txid, LocalTagLookup::LocalTagLookup(const PathID_t &path, uint64_t txid,
const service::Tag &target, const service::Tag &_target,
AbstractContext *ctx) AbstractContext *ctx)
: TagLookup(TXOwner{ctx->OurKey(), txid}, target, ctx, 0) : TagLookup(TXOwner{ctx->OurKey(), txid}, _target, ctx, 0)
, localPath(path) , localPath(path)
{ {
} }

@ -8,11 +8,11 @@ namespace llarp
{ {
namespace dht namespace dht
{ {
RecursiveRouterLookup::RecursiveRouterLookup(const TXOwner &whoasked, RecursiveRouterLookup::RecursiveRouterLookup(const TXOwner &_whoasked,
const RouterID &target, const RouterID &_target,
AbstractContext *ctx, AbstractContext *ctx,
RouterLookupHandler result) RouterLookupHandler result)
: TX< RouterID, RouterContact >(whoasked, target, ctx) : TX< RouterID, RouterContact >(_whoasked, _target, ctx)
, resultHandler(result) , resultHandler(result)
{ {

@ -538,8 +538,8 @@ namespace llarp
} }
/// inbound /// inbound
tcp_conn(llarp_ev_loop* loop, int fd) tcp_conn(llarp_ev_loop* loop, int _fd)
: ev_io(fd, new LosslessWriteQueue_t{}), _conn(nullptr) : ev_io(_fd, new LosslessWriteQueue_t{}), _conn(nullptr)
{ {
tcp.impl = this; tcp.impl = this;
tcp.loop = loop; tcp.loop = loop;
@ -551,9 +551,9 @@ namespace llarp
} }
/// outbound /// outbound
tcp_conn(llarp_ev_loop* loop, int fd, const sockaddr* addr, tcp_conn(llarp_ev_loop* loop, int _fd, const sockaddr* addr,
llarp_tcp_connecter* conn) llarp_tcp_connecter* conn)
: ev_io(fd, new LosslessWriteQueue_t{}), _conn(conn) : ev_io(_fd, new LosslessWriteQueue_t{}), _conn(conn)
{ {
socklen_t slen = sizeof(sockaddr_in); socklen_t slen = sizeof(sockaddr_in);
if(addr->sa_family == AF_INET6) if(addr->sa_family == AF_INET6)
@ -645,8 +645,8 @@ namespace llarp
{ {
llarp_ev_loop* loop; llarp_ev_loop* loop;
llarp_tcp_acceptor* tcp; llarp_tcp_acceptor* tcp;
tcp_serv(llarp_ev_loop* l, int fd, llarp_tcp_acceptor* t) tcp_serv(llarp_ev_loop* l, int _fd, llarp_tcp_acceptor* t)
: ev_io(fd), loop(l), tcp(t) : ev_io(_fd), loop(l), tcp(t)
{ {
tcp->impl = this; tcp->impl = this;
} }

@ -1,5 +1,7 @@
#include "ev_libuv.hpp" #include <ev/ev_libuv.hpp>
#include "net/net_addr.hpp" #include <net/net_addr.hpp>
#include <string.h>
namespace libuv namespace libuv
{ {
@ -517,7 +519,9 @@ namespace libuv
bool bool
Init(uv_loop_t* loop) Init(uv_loop_t* loop)
{ {
strncpy(m_Device->if_name, m_Tun->ifname, sizeof(m_Device->if_name)); std::copy(std::begin(m_Tun->ifname), std::end(m_Tun->ifname),
m_Device->if_name);
memcpy(m_Device->if_name, m_Tun->ifname, sizeof(m_Device->if_name));
if(tuntap_start(m_Device, TUNTAP_MODE_TUNNEL, 0) == -1) if(tuntap_start(m_Device, TUNTAP_MODE_TUNNEL, 0) == -1)
{ {
llarp::LogError("failed to start up ", m_Tun->ifname); llarp::LogError("failed to start up ", m_Tun->ifname);

@ -12,11 +12,11 @@ namespace llarp
namespace exit namespace exit
{ {
BaseSession::BaseSession( BaseSession::BaseSession(
const llarp::RouterID& router, const llarp::RouterID& routerId,
std::function< bool(const llarp_buffer_t&) > writepkt, std::function< bool(const llarp_buffer_t&) > writepkt,
AbstractRouter* r, size_t numpaths, size_t hoplen, bool bundleRC) AbstractRouter* r, size_t numpaths, size_t hoplen, bool bundleRC)
: llarp::path::Builder(r, numpaths, hoplen) : llarp::path::Builder(r, numpaths, hoplen)
, m_ExitRouter(router) , m_ExitRouter(routerId)
, m_WritePacket(writepkt) , m_WritePacket(writepkt)
, m_Counter(0) , m_Counter(0)
, m_LastUse(0) , m_LastUse(0)
@ -82,7 +82,7 @@ namespace llarp
{ {
if(db->Get(m_ExitRouter, cur)) if(db->Get(m_ExitRouter, cur))
return true; return true;
router->LookupRouter(m_ExitRouter, nullptr); m_router->LookupRouter(m_ExitRouter, nullptr);
return false; return false;
} }
@ -113,7 +113,7 @@ namespace llarp
llarp::LogError("Failed to sign exit request"); llarp::LogError("Failed to sign exit request");
return; return;
} }
if(p->SendExitRequest(obtain, router)) if(p->SendExitRequest(obtain, m_router))
llarp::LogInfo("asking ", m_ExitRouter, " for exit"); llarp::LogInfo("asking ", m_ExitRouter, " for exit");
else else
llarp::LogError("failed to send exit request"); llarp::LogError("failed to send exit request");
@ -128,7 +128,7 @@ namespace llarp
bool bool
BaseSession::HandleGotExit(llarp::path::Path_ptr p, llarp_time_t b) BaseSession::HandleGotExit(llarp::path::Path_ptr p, llarp_time_t b)
{ {
m_LastUse = router->Now(); m_LastUse = m_router->Now();
if(b == 0) if(b == 0)
{ {
llarp::LogInfo("obtained an exit via ", p->Endpoint()); llarp::LogInfo("obtained an exit via ", p->Endpoint());
@ -164,7 +164,7 @@ namespace llarp
{ {
llarp::LogInfo(p->Name(), " closing exit path"); llarp::LogInfo(p->Name(), " closing exit path");
routing::CloseExitMessage msg; routing::CloseExitMessage msg;
if(msg.Sign(m_ExitIdentity) && p->SendExitClose(msg, router)) if(msg.Sign(m_ExitIdentity) && p->SendExitClose(msg, m_router))
{ {
p->ClearRoles(roles); p->ClearRoles(roles);
} }
@ -185,12 +185,12 @@ namespace llarp
{ {
LogInfo(p->Name(), " closing exit path"); LogInfo(p->Name(), " closing exit path");
routing::CloseExitMessage msg; routing::CloseExitMessage msg;
if(!(msg.Sign(m_ExitIdentity) && p->SendExitClose(msg, router))) if(!(msg.Sign(m_ExitIdentity) && p->SendExitClose(msg, m_router)))
LogWarn(p->Name(), " failed to send exit close message"); LogWarn(p->Name(), " failed to send exit close message");
} }
}; };
ForEachPath(sendExitClose); ForEachPath(sendExitClose);
router->pathContext().RemovePathSet(shared_from_this()); m_router->pathContext().RemovePathSet(shared_from_this());
return path::Builder::Stop(); return path::Builder::Stop();
} }
@ -204,7 +204,7 @@ namespace llarp
if(!pkt.Load(buf)) if(!pkt.Load(buf))
return false; return false;
m_Downstream.emplace(counter, pkt); m_Downstream.emplace(counter, pkt);
m_LastUse = router->Now(); m_LastUse = m_router->Now();
return true; return true;
} }
@ -217,7 +217,7 @@ namespace llarp
{ {
llarp::LogError("dropped traffic on exit ", m_ExitRouter, " S=", s, llarp::LogError("dropped traffic on exit ", m_ExitRouter, " S=", s,
" P=", path); " P=", path);
p->EnterState(path::ePathIgnore, router->Now()); p->EnterState(path::ePathIgnore, m_router->Now());
return true; return true;
} }
@ -269,7 +269,7 @@ namespace llarp
bool bool
BaseSession::FlushUpstream() BaseSession::FlushUpstream()
{ {
auto now = router->Now(); auto now = m_router->Now();
auto path = PickRandomEstablishedPath(llarp::path::ePathRoleExit); auto path = PickRandomEstablishedPath(llarp::path::ePathRoleExit);
if(path) if(path)
{ {
@ -282,7 +282,7 @@ namespace llarp
if(path) if(path)
{ {
msg.S = path->NextSeqNo(); msg.S = path->NextSeqNo();
if(path->SendRoutingMessage(msg, router)) if(path->SendRoutingMessage(msg, m_router))
m_LastUse = now; m_LastUse = now;
} }
queue.pop_front(); queue.pop_front();
@ -302,7 +302,7 @@ namespace llarp
m_Upstream.clear(); m_Upstream.clear();
if(numHops == 1) if(numHops == 1)
{ {
auto r = router; auto r = m_router;
RouterContact rc; RouterContact rc;
if(r->nodedb()->Get(m_ExitRouter, rc)) if(r->nodedb()->Get(m_ExitRouter, rc))
r->TryConnectAsync(rc, 5); r->TryConnectAsync(rc, 5);

@ -125,7 +125,7 @@ namespace llarp
} }
RouterContact rc; RouterContact rc;
if(!router->nodedb()->Get(connect, rc)) if(!m_router->nodedb()->Get(connect, rc))
{ {
LogError(Name(), " we don't have the RC for ", v, LogError(Name(), " we don't have the RC for ", v,
" so we can't use it in strict-connect"); " so we can't use it in strict-connect");
@ -152,8 +152,8 @@ namespace llarp
} }
m_Exit = std::make_shared< llarp::exit::ExitSession >( m_Exit = std::make_shared< llarp::exit::ExitSession >(
exitRouter, exitRouter,
util::memFn(&TunEndpoint::QueueInboundPacketForExit, this), router, util::memFn(&TunEndpoint::QueueInboundPacketForExit, this),
numPaths, numHops, ShouldBundleRC()); m_router, numPaths, numHops, ShouldBundleRC());
llarp::LogInfo(Name(), " using exit at ", exitRouter); llarp::LogInfo(Name(), " using exit at ", exitRouter);
} }
if(k == "local-dns") if(k == "local-dns")

@ -23,12 +23,6 @@ namespace llarp
{ {
} }
Addr::Addr(const Addr& other)
{
memcpy(&_addr, &other._addr, sizeof(sockaddr_in6));
memcpy(&_addr4, &other._addr4, sizeof(sockaddr_in));
}
void void
Addr::port(uint16_t port) Addr::port(uint16_t port)
{ {

@ -21,8 +21,6 @@ namespace llarp
Addr(); Addr();
Addr(const Addr& other);
Addr(string_view str); Addr(string_view str);
Addr(string_view str, const uint16_t p_port); Addr(string_view str, const uint16_t p_port);

@ -150,7 +150,7 @@ namespace llarp
namespace path namespace path
{ {
Builder::Builder(AbstractRouter* p_router, size_t pathNum, size_t hops) Builder::Builder(AbstractRouter* p_router, size_t pathNum, size_t hops)
: path::PathSet(pathNum), _run(true), router(p_router), numHops(hops) : path::PathSet(pathNum), _run(true), m_router(p_router), numHops(hops)
{ {
CryptoManager::instance()->encryption_keygen(enckey); CryptoManager::instance()->encryption_keygen(enckey);
} }
@ -168,7 +168,7 @@ namespace llarp
ExpirePaths(now); ExpirePaths(now);
if(ShouldBuildMore(now)) if(ShouldBuildMore(now))
BuildOne(); BuildOne();
TickPaths(now, router); TickPaths(now, m_router);
if(m_BuildStats.attempts > 50) if(m_BuildStats.attempts > 50)
{ {
if(m_BuildStats.SuccsessRatio() <= BuildStats::MinGoodRatio if(m_BuildStats.SuccsessRatio() <= BuildStats::MinGoodRatio
@ -204,14 +204,14 @@ namespace llarp
size_t tries = 10; size_t tries = 10;
if(hop == 0) if(hop == 0)
{ {
if(router->NumberOfConnectedRouters() == 0) if(m_router->NumberOfConnectedRouters() == 0)
{ {
// persist connection // persist connection
router->ConnectToRandomRouters(1); m_router->ConnectToRandomRouters(1);
return false; return false;
} }
bool got = false; bool got = false;
router->ForEachPeer( m_router->ForEachPeer(
[&](const ILinkSession* s, bool isOutbound) { [&](const ILinkSession* s, bool isOutbound) {
if(s && s->IsEstablished() && isOutbound && !got) if(s && s->IsEstablished() && isOutbound && !got)
{ {
@ -234,7 +234,7 @@ namespace llarp
if(db->select_random_hop_excluding(cur, excluding)) if(db->select_random_hop_excluding(cur, excluding))
{ {
excluding.insert(cur.pubkey); excluding.insert(cur.pubkey);
if(!router->routerProfiling().IsBadForPath(cur.pubkey)) if(!m_router->routerProfiling().IsBadForPath(cur.pubkey))
return true; return true;
} }
} while(tries > 0); } while(tries > 0);
@ -285,7 +285,7 @@ namespace llarp
Builder::BuildOne(PathRole roles) Builder::BuildOne(PathRole roles)
{ {
std::vector< RouterContact > hops(numHops); std::vector< RouterContact > hops(numHops);
if(SelectHops(router->nodedb(), hops, roles)) if(SelectHops(m_router->nodedb(), hops, roles))
Build(hops, roles); Build(hops, roles);
} }
@ -299,7 +299,7 @@ namespace llarp
std::vector< RouterContact >& hops) std::vector< RouterContact >& hops)
{ {
const auto aligned = const auto aligned =
router->pathContext().FindOwnedPathsWithEndpoint(remote); m_router->pathContext().FindOwnedPathsWithEndpoint(remote);
/// pick the lowest latency path that aligns to remote /// pick the lowest latency path that aligns to remote
/// note: peer exhaustion is made worse happen here /// note: peer exhaustion is made worse happen here
Path_ptr p; Path_ptr p;
@ -332,7 +332,7 @@ namespace llarp
std::set< RouterID > routers{remote}; std::set< RouterID > routers{remote};
hops.resize(numHops); hops.resize(numHops);
auto nodedb = router->nodedb(); auto nodedb = m_router->nodedb();
for(size_t idx = 0; idx < hops.size(); idx++) for(size_t idx = 0; idx < hops.size(); idx++)
{ {
hops[idx].Clear(); hops[idx].Clear();
@ -341,7 +341,7 @@ namespace llarp
// last hop // last hop
if(!nodedb->Get(remote, hops[idx])) if(!nodedb->Get(remote, hops[idx]))
{ {
router->LookupRouter(remote, nullptr); m_router->LookupRouter(remote, nullptr);
return false; return false;
} }
} }
@ -365,7 +365,7 @@ namespace llarp
{ {
std::vector< RouterContact > hops; std::vector< RouterContact > hops;
/// if we really need this path build it "dangerously" /// if we really need this path build it "dangerously"
if(UrgentBuild(router->Now())) if(UrgentBuild(m_router->Now()))
{ {
if(!DoUrgentBuildAlignedTo(remote, hops)) if(!DoUrgentBuildAlignedTo(remote, hops))
{ {
@ -411,7 +411,7 @@ namespace llarp
llarp_time_t llarp_time_t
Builder::Now() const Builder::Now() const
{ {
return router->Now(); return m_router->Now();
} }
void void
@ -422,13 +422,13 @@ namespace llarp
lastBuild = Now(); lastBuild = Now();
// async generate keys // async generate keys
auto ctx = std::make_shared< AsyncPathKeyExchangeContext >(); auto ctx = std::make_shared< AsyncPathKeyExchangeContext >();
ctx->router = router; ctx->router = m_router;
ctx->pathset = GetSelf(); ctx->pathset = GetSelf();
auto path = std::make_shared< path::Path >(hops, this, roles); auto path = std::make_shared< path::Path >(hops, this, roles);
LogInfo(Name(), " build ", path->HopsString()); LogInfo(Name(), " build ", path->HopsString());
path->SetBuildResultHook( path->SetBuildResultHook(
[this](Path_ptr p) { this->HandlePathBuilt(p); }); [this](Path_ptr p) { this->HandlePathBuilt(p); });
ctx->AsyncGenerateKeys(path, router->logic(), router->threadpool(), ctx->AsyncGenerateKeys(path, m_router->logic(), m_router->threadpool(),
&PathBuilderKeysGenerated); &PathBuilderKeysGenerated);
} }
@ -436,7 +436,7 @@ namespace llarp
Builder::HandlePathBuilt(Path_ptr p) Builder::HandlePathBuilt(Path_ptr p)
{ {
buildIntervalLimit = MIN_PATH_BUILD_INTERVAL; buildIntervalLimit = MIN_PATH_BUILD_INTERVAL;
router->routerProfiling().MarkPathSuccess(p.get()); m_router->routerProfiling().MarkPathSuccess(p.get());
LogInfo(p->Name(), " built latency=", p->intro.latency); LogInfo(p->Name(), " built latency=", p->intro.latency);
m_BuildStats.success++; m_BuildStats.success++;
} }
@ -462,7 +462,7 @@ namespace llarp
void void
Builder::HandlePathBuildTimeout(Path_ptr p) Builder::HandlePathBuildTimeout(Path_ptr p)
{ {
router->routerProfiling().MarkPathFail(p.get()); m_router->routerProfiling().MarkPathFail(p.get());
PathSet::HandlePathBuildTimeout(p); PathSet::HandlePathBuildTimeout(p);
DoPathBuildBackoff(); DoPathBuildBackoff();
} }

@ -39,7 +39,7 @@ namespace llarp
std::vector< RouterContact >& hops); std::vector< RouterContact >& hops);
public: public:
AbstractRouter* router; AbstractRouter* m_router;
SecretKey enckey; SecretKey enckey;
size_t numHops; size_t numHops;
llarp_time_t lastBuild = 0; llarp_time_t lastBuild = 0;

@ -22,8 +22,8 @@ namespace llarp
size_t attemptCount = 0; size_t attemptCount = 0;
PendingSession(const RouterContact &rc, LinkLayer_ptr link) PendingSession(const RouterContact &_rc, LinkLayer_ptr _link)
: rc(rc), link(link) : rc(_rc), link(_link)
{ {
} }
}; };

@ -10,11 +10,11 @@ namespace llarp
bool bool
DHTMessage::DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) DHTMessage::DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val)
{ {
llarp::dht::Key_t from; llarp::dht::Key_t fromKey;
from.Zero(); fromKey.Zero();
if(key == "M") if(key == "M")
{ {
return llarp::dht::DecodeMesssageList(from, val, M, true); return llarp::dht::DecodeMesssageList(fromKey, val, M, true);
} }
if(key == "S") if(key == "S")
{ {

@ -17,7 +17,7 @@ namespace llarp
IDataHandler* h, const ConvoTag& t, IDataHandler* h, const ConvoTag& t,
ProtocolType proto) ProtocolType proto)
: logic(l) : logic(l)
, remote(r) , m_remote(r)
, m_LocalIdentity(localident) , m_LocalIdentity(localident)
, introPubKey(introsetPubKey) , introPubKey(introsetPubKey)
, remoteIntro(remote) , remoteIntro(remote)
@ -32,7 +32,7 @@ namespace llarp
{ {
AsyncKeyExchange* self = static_cast< AsyncKeyExchange* >(user); AsyncKeyExchange* self = static_cast< AsyncKeyExchange* >(user);
// put values // put values
self->handler->PutSenderFor(self->msg.tag, self->remote, false); self->handler->PutSenderFor(self->msg.tag, self->m_remote, false);
self->handler->PutCachedSessionKeyFor(self->msg.tag, self->sharedKey); self->handler->PutCachedSessionKeyFor(self->msg.tag, self->sharedKey);
self->handler->PutIntroFor(self->msg.tag, self->remoteIntro); self->handler->PutIntroFor(self->msg.tag, self->remoteIntro);
self->handler->PutReplyIntroFor(self->msg.tag, self->msg.introReply); self->handler->PutReplyIntroFor(self->msg.tag, self->msg.introReply);
@ -55,7 +55,7 @@ namespace llarp
SharedSecret sharedSecret; SharedSecret sharedSecret;
path_dh_func dh_client = util::memFn(&Crypto::dh_client, crypto); path_dh_func dh_client = util::memFn(&Crypto::dh_client, crypto);
if(!self->m_LocalIdentity.KeyExchange(dh_client, sharedSecret, if(!self->m_LocalIdentity.KeyExchange(dh_client, sharedSecret,
self->remote, self->frame.N)) self->m_remote, self->frame.N))
{ {
LogError("failed to derive x25519 shared key component"); LogError("failed to derive x25519 shared key component");
} }

@ -15,7 +15,7 @@ namespace llarp
{ {
std::shared_ptr< Logic > logic; std::shared_ptr< Logic > logic;
SharedSecret sharedKey; SharedSecret sharedKey;
ServiceInfo remote; ServiceInfo m_remote;
const Identity& m_LocalIdentity; const Identity& m_LocalIdentity;
ProtocolMessage msg; ProtocolMessage msg;
ProtocolFrame frame; ProtocolFrame frame;

@ -191,8 +191,8 @@ namespace llarp
{ {
if(!EnsurePathToService( if(!EnsurePathToService(
addr, addr,
[](ABSL_ATTRIBUTE_UNUSED Address addr, [](ABSL_ATTRIBUTE_UNUSED Address _addr,
ABSL_ATTRIBUTE_UNUSED OutboundContext* ctx) {}, ABSL_ATTRIBUTE_UNUSED OutboundContext* _ctx) {},
10000)) 10000))
{ {
LogWarn("failed to ensure path to ", addr); LogWarn("failed to ensure path to ", addr);
@ -893,7 +893,7 @@ namespace llarp
Endpoint::OnLookup(const Address& addr, const IntroSet* introset, Endpoint::OnLookup(const Address& addr, const IntroSet* introset,
const RouterID& endpoint) const RouterID& endpoint)
{ {
const auto now = router->Now(); const auto now = Router()->Now();
auto& fails = m_state->m_ServiceLookupFails; auto& fails = m_state->m_ServiceLookupFails;
auto& lookups = m_state->m_PendingServiceLookups; auto& lookups = m_state->m_PendingServiceLookups;
if(introset == nullptr || introset->IsExpired(now)) if(introset == nullptr || introset->IsExpired(now))

@ -43,7 +43,7 @@ namespace llarp
if(k == "paths") if(k == "paths")
{ {
const auto val = atoi(v.c_str()); const auto val = atoi(v.c_str());
if(val >= 1 && val <= static_cast<int>(path::PathSet::max_paths)) if(val >= 1 && val <= static_cast< int >(path::PathSet::max_paths))
{ {
ep.numPaths = val; ep.numPaths = val;
LogInfo(name, " set number of paths to ", ep.numHops); LogInfo(name, " set number of paths to ", ep.numHops);
@ -56,7 +56,7 @@ namespace llarp
if(k == "hops") if(k == "hops")
{ {
const auto val = atoi(v.c_str()); const auto val = atoi(v.c_str());
if(val >= 1 && val <= static_cast<int>(path::max_len)) if(val >= 1 && val <= static_cast< int >(path::max_len))
{ {
ep.numHops = val; ep.numHops = val;
LogInfo(name, " set number of hops to ", ep.numHops); LogInfo(name, " set number of hops to ", ep.numHops);

@ -66,18 +66,6 @@ namespace llarp
return !(*this == other); return !(*this == other);
} }
ServiceInfo&
operator=(const ServiceInfo& other)
{
enckey = other.enckey;
signkey = other.signkey;
version = other.version;
vanity = other.vanity;
version = other.version;
UpdateAddr();
return *this;
}
bool bool
operator<(const ServiceInfo& other) const operator<(const ServiceInfo& other) const
{ {

@ -13,7 +13,7 @@ namespace llarp
{ {
IServiceLookup::IServiceLookup(ILookupHolder *p, uint64_t tx, IServiceLookup::IServiceLookup(ILookupHolder *p, uint64_t tx,
const std::string &n) const std::string &n)
: parent(p), txid(tx), name(n) : m_parent(p), txid(tx), name(n)
{ {
m_created = time_now_ms(); m_created = time_now_ms();
p->PutLookup(this, tx); p->PutLookup(this, tx);

@ -53,7 +53,7 @@ namespace llarp
bool bool
SendRequestViaPath(path::Path_ptr p, AbstractRouter* r); SendRequestViaPath(path::Path_ptr p, AbstractRouter* r);
ILookupHolder* parent; ILookupHolder* m_parent;
uint64_t txid; uint64_t txid;
const std::string name; const std::string name;
RouterID endpoint; RouterID endpoint;

@ -405,10 +405,10 @@ namespace llarp
LogError("failed to decrypt message"); LogError("failed to decrypt message");
return false; return false;
} }
msg->handler = handler; msg->handler = handler;
const PathID_t from = F; const PathID_t fromPath = F;
logic->queue_func( logic->queue_func(
[=]() { ProtocolMessage::ProcessAsync(recvPath, from, msg); }); [=]() { ProtocolMessage::ProcessAsync(recvPath, fromPath, msg); });
return true; return true;
} }
@ -420,7 +420,7 @@ namespace llarp
} }
bool bool
ProtocolFrame::Verify(const ServiceInfo& from) const ProtocolFrame::Verify(const ServiceInfo& svc) const
{ {
ProtocolFrame copy(*this); ProtocolFrame copy(*this);
// save signature // save signature
@ -439,7 +439,7 @@ namespace llarp
buf.sz = buf.cur - buf.base; buf.sz = buf.cur - buf.base;
buf.cur = buf.base; buf.cur = buf.base;
// verify // verify
return from.Verify(buf, Z); return svc.Verify(buf, Z);
} }
bool bool

@ -11,7 +11,7 @@ namespace llarp
bool bool
CachedTagResult::HandleResponse(const std::set< IntroSet >& introsets) CachedTagResult::HandleResponse(const std::set< IntroSet >& introsets)
{ {
auto now = parent->Now(); auto now = m_parent->Now();
for(const auto& introset : introsets) for(const auto& introset : introsets)
if(result.insert(introset).second) if(result.insert(introset).second)
@ -47,7 +47,7 @@ namespace llarp
{ {
auto msg = std::make_shared< routing::DHTMessage >(); auto msg = std::make_shared< routing::DHTMessage >();
msg->M.emplace_back(std::make_unique< dht::FindIntroMessage >(tag, txid)); msg->M.emplace_back(std::make_unique< dht::FindIntroMessage >(tag, txid));
lastRequest = parent->Now(); lastRequest = m_parent->Now();
return msg; return msg;
} }

@ -22,9 +22,9 @@ namespace llarp
llarp_time_t lastModified = 0; llarp_time_t lastModified = 0;
std::set< IntroSet > result; std::set< IntroSet > result;
Tag tag; Tag tag;
Endpoint* parent; Endpoint* m_parent;
CachedTagResult(const Tag& t, Endpoint* p) : tag(t), parent(p) CachedTagResult(const Tag& t, Endpoint* p) : tag(t), m_parent(p)
{ {
} }

@ -33,13 +33,13 @@ namespace llarp
AlignedBuffer() AlignedBuffer()
{ {
new(&val) Data; new(&m_val) Data;
Zero(); Zero();
} }
explicit AlignedBuffer(const byte_t* data) explicit AlignedBuffer(const byte_t* data)
{ {
new(&val) Data; new(&m_val) Data;
auto& b = as_array(); auto& b = as_array();
for(size_t idx = 0; idx < sz; ++idx) for(size_t idx = 0; idx < sz; ++idx)
{ {
@ -49,7 +49,7 @@ namespace llarp
explicit AlignedBuffer(const Data& buf) explicit AlignedBuffer(const Data& buf)
{ {
new(&val) Data; new(&m_val) Data;
std::copy(buf.begin(), buf.end(), begin()); std::copy(buf.begin(), buf.end(), begin());
} }
@ -164,13 +164,13 @@ namespace llarp
Data& Data&
as_array() as_array()
{ {
return reinterpret_cast< Data& >(val); return reinterpret_cast< Data& >(m_val);
} }
const Data& const Data&
as_array() const as_array() const
{ {
return reinterpret_cast< const Data& >(val); return reinterpret_cast< const Data& >(m_val);
} }
byte_t* byte_t*
@ -282,7 +282,7 @@ namespace llarp
using AlignedStorage = typename std::aligned_storage< sizeof(Data), using AlignedStorage = typename std::aligned_storage< sizeof(Data),
alignof(uint64_t) >:: alignof(uint64_t) >::
type; // why did we align to the nearest double-precision float type; // why did we align to the nearest double-precision float
AlignedStorage val; AlignedStorage m_val;
}; };
} // namespace llarp } // namespace llarp

@ -569,10 +569,10 @@ namespace llarp
print(std::ostream &stream, int level, int spaces) const print(std::ostream &stream, int level, int spaces) const
{ {
Printer::PrintFunction< absl::Duration > durationPrinter = Printer::PrintFunction< absl::Duration > durationPrinter =
[](std::ostream &stream, const absl::Duration &duration, int, [](std::ostream &os, const absl::Duration &duration, int,
int) -> std::ostream & { int) -> std::ostream & {
stream << duration; os << duration;
return stream; return os;
}; };
Printer printer(stream, level, spaces); Printer printer(stream, level, spaces);
printer.printAttribute("records", m_records); printer.printAttribute("records", m_records);

@ -35,10 +35,10 @@ struct TestTx final : public dht::TX< dht::Key_t, Val_t >
struct TestDhtTx : public Test struct TestDhtTx : public Test
{ {
dht::TXOwner asker; dht::TXOwner asker;
dht::Key_t key; dht::Key_t m_key;
TestTx tx; TestTx tx;
TestDhtTx() : tx(asker, key, nullptr) TestDhtTx() : tx(asker, m_key, nullptr)
{ {
} }
}; };

@ -75,22 +75,22 @@ TEST(Catalog, Iterator)
for(size_t i = 0; i < THREAD_COUNT; ++i) for(size_t i = 0; i < THREAD_COUNT; ++i)
{ {
threads[i] = std::thread( threads[i] = std::thread(
[](Barrier *barrier, Cat *catalog, int32_t id) { [](Barrier *b, Cat *cat, int32_t id) {
barrier->Block(); b->Block();
for(size_t i = 0; i < ITERATION_COUNT; ++i) for(size_t j = 0; j < ITERATION_COUNT; ++j)
{ {
int32_t handle = catalog->add(id); int32_t handle = cat->add(id);
absl::optional< int32_t > res = catalog->find(handle); absl::optional< int32_t > res = cat->find(handle);
ASSERT_TRUE(res); ASSERT_TRUE(res);
ASSERT_EQ(res.value(), id); ASSERT_EQ(res.value(), id);
ASSERT_TRUE(catalog->replace(MAX - id, handle)); ASSERT_TRUE(cat->replace(MAX - id, handle));
res = catalog->find(handle); res = cat->find(handle);
ASSERT_TRUE(res); ASSERT_TRUE(res);
ASSERT_EQ(MAX - id, res.value()); ASSERT_EQ(MAX - id, res.value());
int32_t removed = 0; int32_t removed = 0;
ASSERT_TRUE(catalog->remove(handle, &removed)); ASSERT_TRUE(cat->remove(handle, &removed));
ASSERT_EQ(removed, MAX - id); ASSERT_EQ(removed, MAX - id);
ASSERT_FALSE(catalog->find(handle)); ASSERT_FALSE(cat->find(handle));
} }
}, },
&barrier, &catalog, i); &barrier, &catalog, i);
@ -98,11 +98,11 @@ TEST(Catalog, Iterator)
// Verify the length constraint is never violated // Verify the length constraint is never violated
threads[THREAD_COUNT] = std::thread( threads[THREAD_COUNT] = std::thread(
[](Barrier *barrier, Cat *catalog) { [](Barrier *b, Cat *cat) {
barrier->Block(); b->Block();
for(size_t i = 0; i < ITERATION_COUNT; ++i) for(size_t i = 0; i < ITERATION_COUNT; ++i)
{ {
size_t size = catalog->size(); size_t size = cat->size();
ASSERT_LE(size, THREAD_COUNT); ASSERT_LE(size, THREAD_COUNT);
} }
}, },
@ -110,13 +110,13 @@ TEST(Catalog, Iterator)
// Verify that iteration always produces a valid state // Verify that iteration always produces a valid state
threads[THREAD_COUNT + 1] = std::thread( threads[THREAD_COUNT + 1] = std::thread(
[](Barrier *barrier, Cat *catalog) { [](Barrier *b, Cat *cat) {
barrier->Block(); b->Block();
for(size_t i = 0; i < ITERATION_COUNT; ++i) for(size_t i = 0; i < ITERATION_COUNT; ++i)
{ {
int32_t arr[100]; int32_t arr[100];
size_t size = 0; size_t size = 0;
for(Iterator it(catalog); it; ++it) for(Iterator it(cat); it; ++it)
{ {
arr[size++] = it().second; arr[size++] = it().second;
} }
@ -133,6 +133,8 @@ TEST(Catalog, Iterator)
} }
} }
(void)present;
// no duplicate should be there // no duplicate should be there
for(size_t k = j + 1; k < size; k++) for(size_t k = j + 1; k < size; k++)
{ {
@ -145,11 +147,11 @@ TEST(Catalog, Iterator)
// And that we don't have an invalid catalog // And that we don't have an invalid catalog
threads[THREAD_COUNT + 2] = std::thread( threads[THREAD_COUNT + 2] = std::thread(
[](Barrier *barrier, Cat *catalog) { [](Barrier *b, Cat *cat) {
barrier->Block(); b->Block();
for(size_t i = 0; i < ITERATION_COUNT; ++i) for(size_t i = 0; i < ITERATION_COUNT; ++i)
{ {
catalog->verify(); cat->verify();
} }
}, },
&barrier, &catalog); &barrier, &catalog);

@ -272,41 +272,41 @@ TEST(TimerQueue, ThreadSafety)
info[i].first = i; info[i].first = i;
info[i].second = &items[i]; info[i].second = &items[i];
threads[i] = std::thread( threads[i] = std::thread(
[](Info* info, absl::Barrier* barrier, StringQueue* queue) { [](Info* nfo, absl::Barrier* b, StringQueue* q) {
const int THREAD_ID = info->first; const int THREAD_ID = nfo->first;
std::vector< StringItem >* vPtr = info->second; std::vector< StringItem >* vPtr = nfo->second;
// We stagger the removeAll steps among the threads. // We stagger the removeAll steps among the threads.
const int STEP_REMOVE_ALL = THREAD_ID * NUM_REMOVE_ALL / NUM_THREADS; const unsigned int STEP_REMOVE_ALL = THREAD_ID * NUM_REMOVE_ALL / NUM_THREADS;
std::ostringstream oss; std::ostringstream oss;
oss << THREAD_ID; oss << THREAD_ID;
Data V(oss.str()); Data V(oss.str());
barrier->Block(); b->Block();
size_t newSize; size_t newSize;
absl::Time newMinTime; absl::Time newMinTime;
StringItem item; StringItem item;
for(size_t i = 0; i < NUM_ITERATIONS; ++i) for(size_t j = 0; j < NUM_ITERATIONS; ++j)
{ {
const absl::Time TIME = const absl::Time TIME =
absl::Time() + absl::Seconds((i * (i + 3)) % NUM_ITERATIONS); absl::Time() + absl::Seconds((j * (j + 3)) % NUM_ITERATIONS);
int h = queue->add(TIME, V); int h = q->add(TIME, V);
queue->update(h, TIME); q->update(h, TIME);
if(queue->popFront(&item, &newSize, &newMinTime)) if(q->popFront(&item, &newSize, &newMinTime))
{ {
vPtr->push_back(item); vPtr->push_back(item);
} }
h = queue->add(newMinTime, V); h = q->add(newMinTime, V);
queue->popLess(newMinTime, vPtr); q->popLess(newMinTime, vPtr);
if(queue->remove(h, &item, &newSize, &newMinTime)) if(q->remove(h, &item, &newSize, &newMinTime))
{ {
vPtr->push_back(item); vPtr->push_back(item);
} }
if(i % NUM_REMOVE_ALL == STEP_REMOVE_ALL) if(j % NUM_REMOVE_ALL == STEP_REMOVE_ALL)
{ {
queue->removeAll(vPtr); q->removeAll(vPtr);
} }
} }
}, },
@ -314,11 +314,11 @@ TEST(TimerQueue, ThreadSafety)
} }
threads[NUM_THREADS] = std::thread( threads[NUM_THREADS] = std::thread(
[](absl::Barrier* barrier, StringQueue* queue) { [](absl::Barrier* b, StringQueue* q) {
barrier->Block(); b->Block();
for(size_t i = 0; i < NUM_ITERATIONS; ++i) for(size_t i = 0; i < NUM_ITERATIONS; ++i)
{ {
size_t size = queue->size(); size_t size = q->size();
ASSERT_GE(size, 0); ASSERT_GE(size, 0);
ASSERT_LE(size, NUM_THREADS); ASSERT_LE(size, NUM_THREADS);
} }

@ -36,10 +36,10 @@
int int
tuntap_sys_start(struct device *dev, int mode, int tun) tuntap_sys_start(struct device *dev, int mode, int tun)
{ {
int fd; int fd;
int persist; int persist;
char *ifname; char *ifname = NULL;
struct ifreq ifr; struct ifreq ifr;
/* Get the persistence bit */ /* Get the persistence bit */
@ -92,7 +92,7 @@ tuntap_sys_start(struct device *dev, int mode, int tun)
} }
return fd; return fd;
} }
else else
{ {
/* Open the clonable interface */ /* Open the clonable interface */
if((fd = open("/dev/net/tun", O_RDWR)) == -1) if((fd = open("/dev/net/tun", O_RDWR)) == -1)
@ -202,7 +202,7 @@ tuntap_sys_set_ipv6(struct device *dev, t_tun_in6_addr *s6, uint32_t bits)
{ {
struct ifreq ifr; struct ifreq ifr;
struct sockaddr_in6 sai; struct sockaddr_in6 sai;
int sockfd; int sockfd;
struct in6_ifreq ifr6; struct in6_ifreq ifr6;
sockfd = socket(AF_INET6, SOCK_DGRAM, IPPROTO_IP); sockfd = socket(AF_INET6, SOCK_DGRAM, IPPROTO_IP);

@ -157,7 +157,7 @@ tuntap_set_ifname(struct device *dev, const char *ifname)
} }
len = strlen(ifname); len = strlen(ifname);
if(len > IF_NAMESIZE) if(len >= IF_NAMESIZE)
{ {
tuntap_log(TUNTAP_LOG_ERR, "Parameter 'ifname' is too long"); tuntap_log(TUNTAP_LOG_ERR, "Parameter 'ifname' is too long");
return -1; return -1;
@ -169,7 +169,7 @@ tuntap_set_ifname(struct device *dev, const char *ifname)
} }
(void)memset(dev->if_name, 0, IF_NAMESIZE); (void)memset(dev->if_name, 0, IF_NAMESIZE);
(void)strncpy(dev->if_name, ifname, len); (void)strncpy(dev->if_name, ifname, len + 1);
return 0; return 0;
} }

Loading…
Cancel
Save