lokinet/llarp/routing/transfer_traffic_message.hpp
2023-08-30 12:25:47 -07:00

52 lines
1.1 KiB
C++

#pragma once
#include <llarp/crypto/encrypted.hpp>
#include "message.hpp"
#include <llarp/service/protocol_type.hpp>
#include <vector>
namespace llarp
{
namespace routing
{
constexpr size_t ExitPadSize = 512 - 48;
constexpr size_t MaxExitMTU = 1500;
constexpr size_t ExitOverhead = sizeof(uint64_t);
struct TransferTrafficMessage final : public AbstractRoutingMessage
{
std::vector<llarp::Encrypted<MaxExitMTU + ExitOverhead>> X;
service::ProtocolType protocol;
size_t _size = 0;
void
Clear() override
{
X.clear();
_size = 0;
version = 0;
protocol = service::ProtocolType::TrafficV4;
}
size_t
Size() const
{
return _size;
}
/// append buffer to X
bool
PutBuffer(const llarp_buffer_t& buf, uint64_t counter);
bool
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(const llarp_buffer_t& k, llarp_buffer_t* val) override;
bool
HandleMessage(AbstractRoutingMessageHandler* h, AbstractRouter* r) const override;
};
} // namespace routing
} // namespace llarp