2018-06-10 14:05:48 +00:00
|
|
|
#ifndef LLARP_PATH_HPP
|
|
|
|
#define LLARP_PATH_HPP
|
|
|
|
#include <llarp/router.h>
|
|
|
|
#include <llarp/time.h>
|
|
|
|
#include <llarp/aligned.hpp>
|
|
|
|
#include <llarp/crypto.hpp>
|
2018-06-25 15:12:08 +00:00
|
|
|
#include <llarp/dht.hpp>
|
2018-06-22 00:25:30 +00:00
|
|
|
#include <llarp/messages/relay.hpp>
|
2018-06-10 14:05:48 +00:00
|
|
|
#include <llarp/messages/relay_commit.hpp>
|
|
|
|
#include <llarp/path_types.hpp>
|
2018-06-25 15:12:08 +00:00
|
|
|
#include <llarp/pathset.hpp>
|
2018-08-30 18:48:43 +00:00
|
|
|
#include <llarp/pathbuilder.hpp>
|
2018-06-10 14:05:48 +00:00
|
|
|
#include <llarp/router_id.hpp>
|
2018-06-22 13:59:28 +00:00
|
|
|
#include <llarp/routing/handler.hpp>
|
|
|
|
#include <llarp/routing/message.hpp>
|
2018-07-11 16:11:19 +00:00
|
|
|
#include <llarp/service/Intro.hpp>
|
2018-07-25 00:35:11 +00:00
|
|
|
#include <llarp/threading.hpp>
|
2018-06-10 14:05:48 +00:00
|
|
|
|
2018-07-11 13:20:14 +00:00
|
|
|
#include <functional>
|
2018-06-19 17:11:24 +00:00
|
|
|
#include <list>
|
|
|
|
#include <map>
|
2018-06-10 14:05:48 +00:00
|
|
|
#include <unordered_map>
|
|
|
|
#include <vector>
|
|
|
|
|
2018-08-30 18:48:43 +00:00
|
|
|
#define MAXHOPS (8)
|
|
|
|
#define DEFAULT_PATH_LIFETIME (10 * 60 * 1000)
|
2018-09-18 23:56:26 +00:00
|
|
|
#define PATH_BUILD_TIMEOUT (15 * 1000)
|
2018-09-08 15:53:20 +00:00
|
|
|
#define MESSAGE_PAD_SIZE (512)
|
2018-08-30 18:48:43 +00:00
|
|
|
|
2018-06-10 14:05:48 +00:00
|
|
|
namespace llarp
|
|
|
|
{
|
2018-06-25 15:12:08 +00:00
|
|
|
namespace path
|
2018-06-10 14:05:48 +00:00
|
|
|
{
|
2018-06-25 15:12:08 +00:00
|
|
|
struct TransitHopInfo
|
|
|
|
{
|
|
|
|
TransitHopInfo() = default;
|
|
|
|
TransitHopInfo(const TransitHopInfo& other);
|
|
|
|
TransitHopInfo(const RouterID& down, const LR_CommitRecord& record);
|
2018-06-10 14:05:48 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
PathID_t txID, rxID;
|
|
|
|
RouterID upstream;
|
|
|
|
RouterID downstream;
|
2018-06-10 14:05:48 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
friend std::ostream&
|
|
|
|
operator<<(std::ostream& out, const TransitHopInfo& info)
|
|
|
|
{
|
|
|
|
out << "<tx=" << info.txID << " rx=" << info.rxID;
|
|
|
|
out << " upstream=" << info.upstream
|
|
|
|
<< " downstream=" << info.downstream;
|
|
|
|
return out << ">";
|
|
|
|
}
|
2018-06-10 14:05:48 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
bool
|
|
|
|
operator==(const TransitHopInfo& other) const
|
|
|
|
{
|
|
|
|
return txID == other.txID && rxID == other.rxID
|
|
|
|
&& upstream == other.upstream && downstream == other.downstream;
|
|
|
|
}
|
2018-06-10 14:05:48 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
bool
|
|
|
|
operator!=(const TransitHopInfo& other) const
|
|
|
|
{
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
2018-06-10 14:05:48 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
bool
|
|
|
|
operator<(const TransitHopInfo& other) const
|
|
|
|
{
|
|
|
|
return txID < other.txID || rxID < other.rxID
|
|
|
|
|| upstream < other.upstream || downstream < other.downstream;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Hash
|
|
|
|
{
|
|
|
|
std::size_t
|
|
|
|
operator()(TransitHopInfo const& a) const
|
|
|
|
{
|
|
|
|
std::size_t idx0, idx1, idx2, idx3;
|
|
|
|
memcpy(&idx0, a.upstream, sizeof(std::size_t));
|
|
|
|
memcpy(&idx1, a.downstream, sizeof(std::size_t));
|
|
|
|
memcpy(&idx2, a.txID, sizeof(std::size_t));
|
|
|
|
memcpy(&idx3, a.rxID, sizeof(std::size_t));
|
|
|
|
return idx0 ^ idx1 ^ idx2;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
2018-06-18 22:03:50 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
struct PathIDHash
|
2018-06-10 14:05:48 +00:00
|
|
|
{
|
|
|
|
std::size_t
|
2018-06-25 15:12:08 +00:00
|
|
|
operator()(const PathID_t& a) const
|
2018-06-10 14:05:48 +00:00
|
|
|
{
|
2018-06-25 15:12:08 +00:00
|
|
|
std::size_t idx0;
|
|
|
|
memcpy(&idx0, a, sizeof(std::size_t));
|
|
|
|
return idx0;
|
2018-06-10 14:05:48 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
struct IHopHandler
|
2018-06-18 22:03:50 +00:00
|
|
|
{
|
2018-06-25 15:12:08 +00:00
|
|
|
virtual ~IHopHandler(){};
|
2018-06-18 22:03:50 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
virtual bool
|
|
|
|
Expired(llarp_time_t now) const = 0;
|
|
|
|
|
2018-07-24 22:34:46 +00:00
|
|
|
/// send routing message and increment sequence number
|
2018-06-25 15:12:08 +00:00
|
|
|
virtual bool
|
2018-07-24 22:34:46 +00:00
|
|
|
SendRoutingMessage(llarp::routing::IMessage* msg, llarp_router* r) = 0;
|
2018-06-22 00:25:30 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
// handle data in upstream direction
|
|
|
|
virtual bool
|
|
|
|
HandleUpstream(llarp_buffer_t X, const TunnelNonce& Y,
|
|
|
|
llarp_router* r) = 0;
|
2018-06-22 00:25:30 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
// handle data in downstream direction
|
|
|
|
virtual bool
|
|
|
|
HandleDownstream(llarp_buffer_t X, const TunnelNonce& Y,
|
2018-06-22 00:25:30 +00:00
|
|
|
llarp_router* r) = 0;
|
2018-07-24 22:34:46 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
uint64_t m_SequenceNum = 0;
|
2018-06-25 15:12:08 +00:00
|
|
|
};
|
2018-06-22 00:25:30 +00:00
|
|
|
|
2018-06-26 16:23:43 +00:00
|
|
|
struct TransitHop : public IHopHandler,
|
|
|
|
public llarp::routing::IMessageHandler
|
2018-06-25 15:12:08 +00:00
|
|
|
{
|
2018-06-26 16:23:43 +00:00
|
|
|
TransitHop();
|
2018-06-22 00:25:30 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
TransitHop(const TransitHop& other);
|
2018-06-22 00:25:30 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
TransitHopInfo info;
|
|
|
|
SharedSecret pathKey;
|
2018-07-28 22:20:32 +00:00
|
|
|
ShortHash nonceXOR;
|
2018-06-25 15:12:08 +00:00
|
|
|
llarp_time_t started = 0;
|
|
|
|
// 10 minutes default
|
|
|
|
llarp_time_t lifetime = DEFAULT_PATH_LIFETIME;
|
|
|
|
llarp_proto_version_t version;
|
|
|
|
|
2018-10-02 15:00:34 +00:00
|
|
|
bool IsEndpoint(const RouterID & us) const
|
|
|
|
{
|
|
|
|
return info.upstream == us;
|
|
|
|
}
|
|
|
|
|
2018-08-22 16:19:51 +00:00
|
|
|
llarp_time_t
|
|
|
|
ExpireTime() const;
|
2018-06-26 16:23:43 +00:00
|
|
|
llarp::routing::InboundMessageParser m_MessageParser;
|
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
friend std::ostream&
|
|
|
|
operator<<(std::ostream& out, const TransitHop& h)
|
|
|
|
{
|
|
|
|
return out << "[TransitHop " << h.info << " started=" << h.started
|
|
|
|
<< " lifetime=" << h.lifetime << "]";
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Expired(llarp_time_t now) const;
|
2018-06-12 16:45:12 +00:00
|
|
|
|
2018-06-26 16:23:43 +00:00
|
|
|
// send routing message when end of path
|
2018-06-25 15:12:08 +00:00
|
|
|
bool
|
2018-07-24 22:34:46 +00:00
|
|
|
SendRoutingMessage(llarp::routing::IMessage* msg, llarp_router* r);
|
2018-06-22 00:25:30 +00:00
|
|
|
|
2018-06-26 16:23:43 +00:00
|
|
|
// handle routing message when end of path
|
|
|
|
bool
|
|
|
|
HandleRoutingMessage(const llarp::routing::IMessage* msg,
|
|
|
|
llarp_router* r);
|
|
|
|
|
2018-09-11 15:28:36 +00:00
|
|
|
bool
|
|
|
|
HandleDataDiscardMessage(const llarp::routing::DataDiscardMessage* msg,
|
|
|
|
llarp_router* r);
|
|
|
|
|
2018-06-26 16:23:43 +00:00
|
|
|
bool
|
|
|
|
HandlePathConfirmMessage(const llarp::routing::PathConfirmMessage* msg,
|
|
|
|
llarp_router* r);
|
|
|
|
bool
|
|
|
|
HandlePathTransferMessage(const llarp::routing::PathTransferMessage* msg,
|
|
|
|
llarp_router* r);
|
|
|
|
bool
|
|
|
|
HandlePathLatencyMessage(const llarp::routing::PathLatencyMessage* msg,
|
|
|
|
llarp_router* r);
|
|
|
|
|
2018-08-02 00:48:43 +00:00
|
|
|
bool
|
|
|
|
HandleHiddenServiceFrame(const llarp::service::ProtocolFrame* frame)
|
|
|
|
{
|
|
|
|
/// TODO: implement me
|
|
|
|
llarp::LogWarn("Got hidden service data on transit hop");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-07-09 17:32:11 +00:00
|
|
|
bool
|
|
|
|
HandleGotIntroMessage(const llarp::dht::GotIntroMessage* msg);
|
|
|
|
|
2018-06-26 16:23:43 +00:00
|
|
|
bool
|
|
|
|
HandleDHTMessage(const llarp::dht::IMessage* msg, llarp_router* r);
|
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
// handle data in upstream direction
|
|
|
|
bool
|
|
|
|
HandleUpstream(llarp_buffer_t X, const TunnelNonce& Y, llarp_router* r);
|
2018-06-18 22:03:50 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
// handle data in downstream direction
|
|
|
|
bool
|
|
|
|
HandleDownstream(llarp_buffer_t X, const TunnelNonce& Y, llarp_router* r);
|
|
|
|
};
|
|
|
|
|
|
|
|
/// configuration for a single hop when building a path
|
|
|
|
struct PathHopConfig
|
2018-06-22 00:25:30 +00:00
|
|
|
{
|
2018-06-25 15:12:08 +00:00
|
|
|
/// path id
|
|
|
|
PathID_t txID, rxID;
|
|
|
|
// router contact of router
|
2018-08-30 18:48:43 +00:00
|
|
|
RouterContact rc;
|
2018-06-25 15:12:08 +00:00
|
|
|
// temp public encryption key
|
|
|
|
SecretKey commkey;
|
|
|
|
/// shared secret at this hop
|
|
|
|
SharedSecret shared;
|
2018-07-28 22:20:32 +00:00
|
|
|
/// hash of shared secret used for nonce mutation
|
|
|
|
ShortHash nonceXOR;
|
2018-06-25 15:12:08 +00:00
|
|
|
/// next hop's router id
|
|
|
|
RouterID upstream;
|
|
|
|
/// nonce for key exchange
|
|
|
|
TunnelNonce nonce;
|
|
|
|
// lifetime
|
|
|
|
llarp_time_t lifetime = DEFAULT_PATH_LIFETIME;
|
|
|
|
|
|
|
|
~PathHopConfig();
|
|
|
|
PathHopConfig();
|
|
|
|
};
|
2018-06-22 00:25:30 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
/// A path we made
|
|
|
|
struct Path : public IHopHandler, public llarp::routing::IMessageHandler
|
|
|
|
{
|
|
|
|
typedef std::function< void(Path*) > BuildResultHookFunc;
|
2018-09-13 12:27:28 +00:00
|
|
|
typedef std::function< bool(Path*, llarp_time_t) > CheckForDeadFunc;
|
2018-09-11 15:28:36 +00:00
|
|
|
typedef std::function< bool(Path*, const PathID_t&, uint64_t) >
|
|
|
|
DropHandlerFunc;
|
2018-06-25 15:12:08 +00:00
|
|
|
typedef std::vector< PathHopConfig > HopList;
|
2018-09-18 21:32:17 +00:00
|
|
|
typedef std::function< bool(Path*, const service::ProtocolFrame*) >
|
2018-08-02 00:48:43 +00:00
|
|
|
DataHandlerFunc;
|
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
HopList hops;
|
2018-07-11 16:11:19 +00:00
|
|
|
|
2018-09-26 13:04:25 +00:00
|
|
|
PathSet* m_PathSet;
|
|
|
|
|
2018-07-11 16:11:19 +00:00
|
|
|
llarp::service::Introduction intro;
|
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
llarp_time_t buildStarted;
|
2018-09-13 13:07:00 +00:00
|
|
|
PathStatus _status;
|
2018-06-19 17:11:24 +00:00
|
|
|
|
2018-09-26 13:04:25 +00:00
|
|
|
Path(const std::vector< RouterContact >& routers, PathSet* parent);
|
2018-06-19 17:11:24 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
void
|
|
|
|
SetBuildResultHook(BuildResultHookFunc func);
|
2018-06-22 00:25:30 +00:00
|
|
|
|
2018-08-02 00:48:43 +00:00
|
|
|
void
|
|
|
|
SetDataHandler(DataHandlerFunc func)
|
|
|
|
{
|
|
|
|
m_DataHandler = func;
|
|
|
|
}
|
|
|
|
|
2018-09-11 15:28:36 +00:00
|
|
|
void
|
|
|
|
SetDropHandler(DropHandlerFunc func)
|
|
|
|
{
|
|
|
|
m_DropHandler = func;
|
|
|
|
}
|
|
|
|
|
2018-09-13 12:27:28 +00:00
|
|
|
void
|
|
|
|
SetDeadChecker(CheckForDeadFunc func)
|
|
|
|
{
|
|
|
|
m_CheckForDead = func;
|
|
|
|
}
|
|
|
|
|
2018-09-13 13:07:00 +00:00
|
|
|
void
|
2018-09-14 14:50:37 +00:00
|
|
|
EnterState(PathStatus st);
|
2018-09-13 13:07:00 +00:00
|
|
|
|
2018-08-14 21:17:18 +00:00
|
|
|
llarp_time_t
|
|
|
|
ExpireTime() const
|
|
|
|
{
|
|
|
|
return buildStarted + hops[0].lifetime;
|
|
|
|
}
|
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
bool
|
|
|
|
Expired(llarp_time_t now) const;
|
2018-06-10 14:05:48 +00:00
|
|
|
|
2018-06-29 16:02:39 +00:00
|
|
|
void
|
|
|
|
Tick(llarp_time_t now, llarp_router* r);
|
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
bool
|
2018-07-24 22:34:46 +00:00
|
|
|
SendRoutingMessage(llarp::routing::IMessage* msg, llarp_router* r);
|
2018-06-19 17:11:24 +00:00
|
|
|
|
2018-09-11 15:28:36 +00:00
|
|
|
bool
|
|
|
|
HandleDataDiscardMessage(const llarp::routing::DataDiscardMessage* msg,
|
|
|
|
llarp_router* r);
|
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
bool
|
2018-06-26 16:23:43 +00:00
|
|
|
HandlePathConfirmMessage(const llarp::routing::PathConfirmMessage* msg,
|
|
|
|
llarp_router* r);
|
2018-06-19 17:11:24 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
bool
|
2018-06-26 16:23:43 +00:00
|
|
|
HandlePathLatencyMessage(const llarp::routing::PathLatencyMessage* msg,
|
|
|
|
llarp_router* r);
|
2018-06-19 17:11:24 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
bool
|
2018-06-26 16:23:43 +00:00
|
|
|
HandlePathTransferMessage(const llarp::routing::PathTransferMessage* msg,
|
|
|
|
llarp_router* r);
|
|
|
|
|
2018-08-02 00:48:43 +00:00
|
|
|
bool
|
|
|
|
HandleHiddenServiceFrame(const llarp::service::ProtocolFrame* frame);
|
|
|
|
|
2018-07-09 17:32:11 +00:00
|
|
|
bool
|
|
|
|
HandleGotIntroMessage(const llarp::dht::GotIntroMessage* msg);
|
|
|
|
|
2018-06-26 16:23:43 +00:00
|
|
|
bool
|
|
|
|
HandleDHTMessage(const llarp::dht::IMessage* msg, llarp_router* r);
|
2018-06-22 00:25:30 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
bool
|
|
|
|
HandleRoutingMessage(llarp_buffer_t buf, llarp_router* r);
|
2018-06-22 00:25:30 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
// handle data in upstream direction
|
|
|
|
bool
|
|
|
|
HandleUpstream(llarp_buffer_t X, const TunnelNonce& Y, llarp_router* r);
|
2018-06-22 00:25:30 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
// handle data in downstream direction
|
|
|
|
bool
|
|
|
|
HandleDownstream(llarp_buffer_t X, const TunnelNonce& Y, llarp_router* r);
|
2018-06-19 17:11:24 +00:00
|
|
|
|
2018-07-11 16:11:19 +00:00
|
|
|
bool
|
|
|
|
IsReady() const;
|
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
// Is this deprecated?
|
|
|
|
// nope not deprecated :^DDDD
|
|
|
|
const PathID_t&
|
|
|
|
TXID() const;
|
2018-06-23 11:28:37 +00:00
|
|
|
|
2018-07-23 07:38:29 +00:00
|
|
|
RouterID
|
|
|
|
Endpoint() const;
|
|
|
|
|
2018-09-24 11:36:47 +00:00
|
|
|
bool
|
|
|
|
IsEndpoint(const RouterID& router, const PathID_t& path) const;
|
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
const PathID_t&
|
|
|
|
RXID() const;
|
2018-06-19 17:11:24 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
RouterID
|
|
|
|
Upstream() const;
|
2018-06-22 13:59:28 +00:00
|
|
|
|
2018-09-13 13:07:00 +00:00
|
|
|
std::string
|
|
|
|
Name() const;
|
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
protected:
|
|
|
|
llarp::routing::InboundMessageParser m_InboundMessageParser;
|
2018-06-10 14:05:48 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
private:
|
|
|
|
BuildResultHookFunc m_BuiltHook;
|
2018-08-02 00:48:43 +00:00
|
|
|
DataHandlerFunc m_DataHandler;
|
2018-09-11 15:28:36 +00:00
|
|
|
DropHandlerFunc m_DropHandler;
|
2018-09-13 12:27:28 +00:00
|
|
|
CheckForDeadFunc m_CheckForDead;
|
2018-09-24 11:36:47 +00:00
|
|
|
llarp_time_t m_LastRecvMessage = 0;
|
2018-06-26 16:23:43 +00:00
|
|
|
llarp_time_t m_LastLatencyTestTime = 0;
|
|
|
|
uint64_t m_LastLatencyTestID = 0;
|
2018-06-25 15:12:08 +00:00
|
|
|
};
|
2018-06-10 14:05:48 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
enum PathBuildStatus
|
|
|
|
{
|
|
|
|
ePathBuildSuccess,
|
|
|
|
ePathBuildTimeout,
|
|
|
|
ePathBuildReject
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PathContext
|
|
|
|
{
|
|
|
|
PathContext(llarp_router* router);
|
|
|
|
~PathContext();
|
2018-06-10 14:05:48 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
/// called from router tick function
|
|
|
|
void
|
|
|
|
ExpirePaths();
|
2018-06-18 22:03:50 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
/// called from router tick function
|
|
|
|
/// builds all paths we need to build at current tick
|
|
|
|
void
|
|
|
|
BuildPaths();
|
2018-06-10 14:05:48 +00:00
|
|
|
|
2018-06-29 16:02:39 +00:00
|
|
|
/// called from router tick function
|
|
|
|
void
|
|
|
|
TickPaths();
|
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
/// track a path builder with this context
|
|
|
|
void
|
2018-08-30 18:48:43 +00:00
|
|
|
AddPathBuilder(Builder* set);
|
2018-06-10 14:05:48 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
void
|
|
|
|
AllowTransit();
|
|
|
|
void
|
|
|
|
RejectTransit();
|
2018-06-10 14:05:48 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
bool
|
|
|
|
AllowingTransit() const;
|
2018-06-10 14:05:48 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
bool
|
|
|
|
HasTransitHop(const TransitHopInfo& info);
|
2018-06-22 00:25:30 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
bool
|
|
|
|
HandleRelayCommit(const LR_CommitMessage* msg);
|
2018-06-22 00:25:30 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
void
|
|
|
|
PutTransitHop(TransitHop* hop);
|
2018-06-12 16:45:12 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
IHopHandler*
|
|
|
|
GetByUpstream(const RouterID& id, const PathID_t& path);
|
2018-06-12 16:45:12 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
IHopHandler*
|
|
|
|
GetByDownstream(const RouterID& id, const PathID_t& path);
|
2018-06-12 16:45:12 +00:00
|
|
|
|
2018-07-09 17:32:11 +00:00
|
|
|
PathSet*
|
|
|
|
GetLocalPathSet(const PathID_t& id);
|
|
|
|
|
2018-08-10 21:34:11 +00:00
|
|
|
routing::IMessageHandler*
|
|
|
|
GetHandler(const PathID_t& id);
|
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
bool
|
|
|
|
ForwardLRCM(const RouterID& nextHop,
|
2018-08-30 18:48:43 +00:00
|
|
|
const std::array< EncryptedFrame, 8 >& frames);
|
2018-06-22 00:25:30 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
bool
|
|
|
|
HopIsUs(const PubKey& k) const;
|
2018-06-22 00:25:30 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
bool
|
|
|
|
HandleLRUM(const RelayUpstreamMessage* msg);
|
2018-06-19 17:11:24 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
bool
|
|
|
|
HandleLRDM(const RelayDownstreamMessage* msg);
|
2018-06-10 14:05:48 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
void
|
|
|
|
AddOwnPath(PathSet* set, Path* p);
|
2018-06-12 16:45:12 +00:00
|
|
|
|
2018-08-18 14:01:21 +00:00
|
|
|
void
|
2018-08-30 18:48:43 +00:00
|
|
|
RemovePathBuilder(Builder* ctx);
|
2018-08-18 14:01:21 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
RemovePathSet(PathSet* set);
|
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
typedef std::multimap< PathID_t, TransitHop* > TransitHopsMap_t;
|
2018-06-19 17:11:24 +00:00
|
|
|
|
2018-08-12 17:22:29 +00:00
|
|
|
typedef std::pair< util::Mutex, TransitHopsMap_t > SyncTransitMap_t;
|
2018-06-19 17:11:24 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
// maps path id -> pathset owner of path
|
|
|
|
typedef std::map< PathID_t, PathSet* > OwnedPathsMap_t;
|
2018-06-12 16:45:12 +00:00
|
|
|
|
2018-08-12 17:22:29 +00:00
|
|
|
typedef std::pair< util::Mutex, OwnedPathsMap_t > SyncOwnedPathsMap_t;
|
2018-06-12 16:45:12 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
llarp_threadpool*
|
|
|
|
Worker();
|
2018-06-15 14:33:38 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
llarp_crypto*
|
|
|
|
Crypto();
|
2018-06-22 00:25:30 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
llarp_logic*
|
|
|
|
Logic();
|
2018-06-12 16:45:12 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
llarp_router*
|
|
|
|
Router();
|
2018-06-18 22:03:50 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
byte_t*
|
|
|
|
EncryptionSecretKey();
|
2018-06-12 16:45:12 +00:00
|
|
|
|
2018-06-25 15:12:08 +00:00
|
|
|
const byte_t*
|
|
|
|
OurRouterID() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
llarp_router* m_Router;
|
|
|
|
SyncTransitMap_t m_TransitPaths;
|
|
|
|
SyncTransitMap_t m_Paths;
|
|
|
|
SyncOwnedPathsMap_t m_OurPaths;
|
2018-08-30 18:48:43 +00:00
|
|
|
std::list< Builder* > m_PathBuilders;
|
2018-06-25 15:12:08 +00:00
|
|
|
bool m_AllowTransit;
|
|
|
|
};
|
|
|
|
} // namespace path
|
2018-06-18 22:03:50 +00:00
|
|
|
} // namespace llarp
|
2018-06-10 14:05:48 +00:00
|
|
|
|
2018-06-14 20:13:07 +00:00
|
|
|
#endif
|