mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-05 21:20:38 +00:00
38fd0552d3
Success case: - the path endpoint creates and sends a LR_StatusMessage upon successful path creation Failure case: - an intermediate hop creates and sends a LR_StatusMessage upon failure to forward the path to the next hop for any reason Both cases: - transit hops receive LR_StatusMessages and add a frame to them reflecting their "status" with respect to that path - the path creator receives LR_StatusMessages and decrypts/parses the LR_StatusRecord frames from the path hops. If all is good, the Path does as it would when receiving a PathConfirmMessage. If not, the Path marks the new path as failed. LR_StatusMessage is now used/sent in place of PathConfirmMessage
71 lines
1.5 KiB
C++
71 lines
1.5 KiB
C++
#ifndef LLARP_PATH_IHOPHANDLER_HPP
|
|
#define LLARP_PATH_IHOPHANDLER_HPP
|
|
|
|
#include <crypto/types.hpp>
|
|
#include <util/types.hpp>
|
|
#include <crypto/encrypted_frame.hpp>
|
|
|
|
#include <memory>
|
|
|
|
struct llarp_buffer_t;
|
|
|
|
namespace llarp
|
|
{
|
|
struct AbstractRouter;
|
|
|
|
namespace routing
|
|
{
|
|
struct IMessage;
|
|
}
|
|
|
|
namespace path
|
|
{
|
|
struct IHopHandler
|
|
{
|
|
virtual ~IHopHandler()
|
|
{
|
|
}
|
|
|
|
virtual bool
|
|
Expired(llarp_time_t now) const = 0;
|
|
|
|
virtual bool
|
|
ExpiresSoon(llarp_time_t now, llarp_time_t dlt) const = 0;
|
|
|
|
/// send routing message and increment sequence number
|
|
virtual bool
|
|
SendRoutingMessage(const routing::IMessage& msg, AbstractRouter* r) = 0;
|
|
|
|
// handle data in upstream direction
|
|
virtual bool
|
|
HandleUpstream(const llarp_buffer_t& X, const TunnelNonce& Y,
|
|
AbstractRouter* r) = 0;
|
|
|
|
// handle data in downstream direction
|
|
virtual bool
|
|
HandleDownstream(const llarp_buffer_t& X, const TunnelNonce& Y,
|
|
AbstractRouter* r) = 0;
|
|
|
|
/// return timestamp last remote activity happened at
|
|
virtual llarp_time_t
|
|
LastRemoteActivityAt() const = 0;
|
|
|
|
virtual bool
|
|
HandleLRSM(uint64_t status, std::array< EncryptedFrame, 8 >& frames,
|
|
AbstractRouter* r) = 0;
|
|
|
|
uint64_t
|
|
NextSeqNo()
|
|
{
|
|
return m_SequenceNum++;
|
|
}
|
|
|
|
protected:
|
|
uint64_t m_SequenceNum = 0;
|
|
};
|
|
|
|
using HopHandler_ptr = std::shared_ptr< IHopHandler >;
|
|
} // namespace path
|
|
} // namespace llarp
|
|
#endif
|