2021-03-09 22:24:35 +00:00
|
|
|
#pragma once
|
|
|
|
|
2023-11-06 20:59:33 +00:00
|
|
|
#include "path_types.hpp"
|
2023-11-06 21:02:20 +00:00
|
|
|
|
2023-10-24 13:18:03 +00:00
|
|
|
#include <llarp/crypto/types.hpp>
|
|
|
|
#include <llarp/util/decaying_hashset.hpp>
|
|
|
|
#include <llarp/util/types.hpp>
|
|
|
|
|
2019-06-17 23:19:39 +00:00
|
|
|
#include <memory>
|
2023-10-24 13:18:03 +00:00
|
|
|
#include <vector>
|
2019-06-17 23:19:39 +00:00
|
|
|
|
|
|
|
struct llarp_buffer_t;
|
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
2024-02-01 12:43:43 +00:00
|
|
|
struct Router;
|
2019-06-17 23:19:39 +00:00
|
|
|
|
2024-02-01 12:43:43 +00:00
|
|
|
namespace routing
|
|
|
|
{
|
|
|
|
struct AbstractRoutingMessage;
|
|
|
|
}
|
2019-06-17 23:19:39 +00:00
|
|
|
|
2024-02-01 12:43:43 +00:00
|
|
|
namespace path
|
|
|
|
{
|
2023-10-21 03:30:10 +00:00
|
|
|
|
2024-02-01 12:43:43 +00:00
|
|
|
std::string make_onion_payload(
|
|
|
|
const SymmNonce& nonce, const PathID_t& path_id, const std::string_view& inner_payload);
|
|
|
|
std::string make_onion_payload(
|
|
|
|
const SymmNonce& nonce, const PathID_t& path_id, const ustring_view& inner_payload);
|
2023-10-21 03:30:10 +00:00
|
|
|
|
2024-02-01 12:43:43 +00:00
|
|
|
struct AbstractHopHandler
|
|
|
|
{
|
|
|
|
virtual ~AbstractHopHandler() = default;
|
|
|
|
|
|
|
|
virtual PathID_t RXID() const = 0;
|
|
|
|
|
|
|
|
virtual bool Expired(llarp_time_t now) const = 0;
|
|
|
|
|
|
|
|
virtual bool ExpiresSoon(llarp_time_t now, llarp_time_t dlt) const = 0;
|
|
|
|
|
|
|
|
/// sends a control request along a path
|
|
|
|
///
|
|
|
|
/// performs the necessary onion encryption before sending.
|
|
|
|
/// func will be called when a timeout occurs or a response is received.
|
|
|
|
/// if a response is received, onion decryption is performed before func is called.
|
|
|
|
///
|
|
|
|
/// func is called with a bt-encoded response string (if applicable), and
|
|
|
|
/// a timeout flag (if set, response string will be empty)
|
|
|
|
virtual bool send_path_control_message(
|
|
|
|
std::string method, std::string body, std::function<void(std::string)> func) = 0;
|
|
|
|
|
|
|
|
/// return timestamp last remote activity happened at
|
|
|
|
virtual llarp_time_t LastRemoteActivityAt() const = 0;
|
|
|
|
|
|
|
|
// TODO: remove this method after all commented out uses are deleted
|
|
|
|
uint64_t NextSeqNo()
|
|
|
|
{
|
|
|
|
return m_SequenceNum++;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
uint64_t m_SequenceNum = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
// using HopHandler_ptr = std::shared_ptr<AbstractHopHandler>;
|
|
|
|
} // namespace path
|
2019-06-17 23:19:39 +00:00
|
|
|
} // namespace llarp
|