2018-07-11 13:20:14 +00:00
|
|
|
#ifndef LLARP_DHT_MESSAGE_HPP
|
|
|
|
#define LLARP_DHT_MESSAGE_HPP
|
2018-11-05 11:27:12 +00:00
|
|
|
|
2019-01-13 22:39:10 +00:00
|
|
|
#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>
|
2019-01-10 19:41:51 +00:00
|
|
|
#include <util/bencode.hpp>
|
2018-12-12 02:52:51 +00:00
|
|
|
|
2018-07-11 13:20:14 +00:00
|
|
|
#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
|
2018-07-11 13:20:14 +00:00
|
|
|
{
|
|
|
|
virtual ~IMessage(){};
|
|
|
|
|
|
|
|
/// construct
|
|
|
|
IMessage(const Key_t& from) : From(from)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool
|
2018-09-02 18:25:42 +00:00
|
|
|
HandleMessage(
|
2018-12-10 16:26:46 +00:00
|
|
|
struct llarp_dht_context* dht,
|
2018-09-02 18:25:42 +00:00
|
|
|
std::vector< std::unique_ptr< IMessage > >& replies) const = 0;
|
2018-07-11 13:20:14 +00:00
|
|
|
|
|
|
|
Key_t From;
|
|
|
|
PathID_t pathID;
|
|
|
|
};
|
|
|
|
|
2018-09-02 18:25:42 +00:00
|
|
|
std::unique_ptr< IMessage >
|
2018-07-11 13:20:14 +00:00
|
|
|
DecodeMessage(const Key_t& from, llarp_buffer_t* buf, bool relayed = false);
|
|
|
|
|
|
|
|
bool
|
2018-09-02 18:25:42 +00:00
|
|
|
DecodeMesssageList(Key_t from, llarp_buffer_t* buf,
|
|
|
|
std::vector< std::unique_ptr< IMessage > >& dst,
|
|
|
|
bool relayed = false);
|
2018-07-17 04:37:50 +00:00
|
|
|
} // namespace dht
|
|
|
|
} // namespace llarp
|
2018-07-11 13:20:14 +00:00
|
|
|
|
2018-08-29 20:40:26 +00:00
|
|
|
#endif
|