2018-12-27 14:32:37 +00:00
|
|
|
#ifndef LLARP_ROUTING_MESSAGE_PARSER_HPP
|
|
|
|
#define LLARP_ROUTING_MESSAGE_PARSER_HPP
|
2019-01-10 19:41:51 +00:00
|
|
|
|
2019-02-11 19:45:42 +00:00
|
|
|
#include <util/bencode.h>
|
2019-02-02 23:12:42 +00:00
|
|
|
#include <util/buffer.hpp>
|
2018-12-27 14:32:37 +00:00
|
|
|
|
2019-02-11 19:45:42 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2019-01-10 19:41:51 +00:00
|
|
|
namespace llarp
|
2018-12-27 14:32:37 +00:00
|
|
|
{
|
2019-02-11 19:45:42 +00:00
|
|
|
struct AbstractRouter;
|
|
|
|
struct PathID_t;
|
2018-12-27 14:32:37 +00:00
|
|
|
|
2019-01-10 19:41:51 +00:00
|
|
|
namespace routing
|
2018-12-27 14:32:37 +00:00
|
|
|
{
|
2019-02-11 19:45:42 +00:00
|
|
|
struct IMessage;
|
2018-12-27 14:32:37 +00:00
|
|
|
struct IMessageHandler;
|
|
|
|
|
|
|
|
struct InboundMessageParser
|
|
|
|
{
|
|
|
|
InboundMessageParser();
|
2019-02-11 19:45:42 +00:00
|
|
|
~InboundMessageParser();
|
2018-12-27 14:32:37 +00:00
|
|
|
|
|
|
|
bool
|
2020-04-07 18:38:56 +00:00
|
|
|
ParseMessageBuffer(
|
|
|
|
const llarp_buffer_t& buf,
|
|
|
|
IMessageHandler* handler,
|
|
|
|
const PathID_t& from,
|
|
|
|
AbstractRouter* r);
|
2018-12-27 14:32:37 +00:00
|
|
|
|
2019-05-22 00:36:03 +00:00
|
|
|
bool
|
|
|
|
operator()(llarp_buffer_t* buffer, llarp_buffer_t* key);
|
2019-02-11 19:45:42 +00:00
|
|
|
|
2019-05-22 00:36:03 +00:00
|
|
|
private:
|
2019-11-03 15:31:01 +00:00
|
|
|
uint64_t version = 0;
|
2019-07-30 23:42:13 +00:00
|
|
|
bool firstKey{false};
|
|
|
|
char ourKey{'\0'};
|
2019-02-11 19:45:42 +00:00
|
|
|
struct MessageHolder;
|
|
|
|
|
2019-07-30 23:42:13 +00:00
|
|
|
IMessage* msg{nullptr};
|
2020-04-07 18:38:56 +00:00
|
|
|
std::unique_ptr<MessageHolder> m_Holder;
|
2018-12-27 14:32:37 +00:00
|
|
|
};
|
2019-01-17 14:02:50 +00:00
|
|
|
} // namespace routing
|
|
|
|
} // namespace llarp
|
2019-01-10 19:41:51 +00:00
|
|
|
#endif
|