lokinet/llarp/routing/message.hpp

46 lines
886 B
C++
Raw Normal View History

#pragma once
#include <llarp/constants/proto.hpp>
#include <llarp/path/path_types.hpp>
#include <llarp/util/bencode.hpp>
#include <llarp/util/buffer.hpp>
namespace llarp
{
struct AbstractRouter;
namespace routing
{
struct IMessageHandler;
2019-05-24 02:01:36 +00:00
struct IMessage
{
PathID_t from;
2019-07-30 23:42:13 +00:00
uint64_t S{0};
2022-05-26 15:59:44 +00:00
uint64_t version = llarp::constants::proto_version;
2018-09-17 15:32:37 +00:00
2019-07-30 23:42:13 +00:00
IMessage() = default;
2018-09-17 15:32:37 +00:00
2019-07-30 23:42:13 +00:00
virtual ~IMessage() = default;
2018-09-17 15:32:37 +00:00
2019-05-24 02:01:36 +00:00
virtual bool
BEncode(llarp_buffer_t* buf) const = 0;
virtual bool
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf) = 0;
virtual bool
HandleMessage(IMessageHandler* h, AbstractRouter* r) const = 0;
virtual void
Clear() = 0;
bool
operator<(const IMessage& other) const
{
return other.S < S;
}
};
} // namespace routing
} // namespace llarp