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
|
2019-02-01 01:58:06 +00:00
|
|
|
ParseMessageBuffer(const llarp_buffer_t& buf, IMessageHandler* handler,
|
2019-02-11 19:45:42 +00:00
|
|
|
const PathID_t& from, AbstractRouter* r);
|
2018-12-27 14:32:37 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
static bool
|
|
|
|
OnKey(dict_reader* r, llarp_buffer_t* key);
|
2019-02-11 19:45:42 +00:00
|
|
|
|
2018-12-27 14:32:37 +00:00
|
|
|
bool firstKey;
|
|
|
|
char key;
|
|
|
|
dict_reader reader;
|
2019-01-10 19:41:51 +00:00
|
|
|
|
2019-02-11 19:45:42 +00:00
|
|
|
struct MessageHolder;
|
|
|
|
|
|
|
|
IMessage* msg;
|
|
|
|
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
|