lokinet/llarp/dht/message.hpp

49 lines
1000 B
C++
Raw Normal View History

#ifndef LLARP_DHT_MESSAGE_HPP
#define LLARP_DHT_MESSAGE_HPP
#include <dht/dht.h>
2018-12-12 00:48:54 +00:00
#include <dht/key.hpp>
2019-01-11 01:19:36 +00:00
#include <path/path_types.hpp>
#include <util/bencode.hpp>
#include <vector>
namespace llarp
{
namespace dht
{
constexpr size_t MAX_MSG_SIZE = 2048;
2019-01-10 17:43:29 +00:00
struct IMessage : public IBEncodeMessage
{
virtual ~IMessage()
{
}
/// construct
IMessage(const Key_t& from) : From(from)
{
}
2019-05-03 13:15:03 +00:00
using Ptr_t = std::unique_ptr< IMessage >;
virtual bool
2019-05-03 13:15:03 +00:00
HandleMessage(struct llarp_dht_context* dht,
std::vector< Ptr_t >& replies) const = 0;
Key_t From;
PathID_t pathID;
};
2019-05-03 13:15:03 +00:00
IMessage::Ptr_t
DecodeMessage(const Key_t& from, llarp_buffer_t* buf, bool relayed = false);
bool
DecodeMesssageList(Key_t from, llarp_buffer_t* buf,
2019-05-03 13:15:03 +00:00
std::vector< IMessage::Ptr_t >& dst,
bool relayed = false);
2018-07-17 04:37:50 +00:00
} // namespace dht
} // namespace llarp
2018-08-29 20:40:26 +00:00
#endif