2018-06-22 13:59:28 +00:00
|
|
|
#ifndef LLARP_ROUTING_MESSAGE_HPP
|
|
|
|
#define LLARP_ROUTING_MESSAGE_HPP
|
|
|
|
|
|
|
|
#include <llarp/buffer.h>
|
|
|
|
#include <llarp/router.h>
|
2018-06-23 00:00:44 +00:00
|
|
|
#include <llarp/bencode.hpp>
|
2018-06-22 13:59:28 +00:00
|
|
|
#include <llarp/path_types.hpp>
|
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace routing
|
|
|
|
{
|
|
|
|
struct IMessageHandler;
|
|
|
|
|
2018-06-23 00:00:44 +00:00
|
|
|
struct IMessage : public llarp::IBEncodeMessage
|
2018-06-22 13:59:28 +00:00
|
|
|
{
|
|
|
|
llarp::PathID_t from;
|
2018-07-23 21:59:43 +00:00
|
|
|
uint64_t S = 0;
|
2018-09-17 15:32:37 +00:00
|
|
|
|
|
|
|
IMessage() : llarp::IBEncodeMessage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-09-17 16:12:42 +00:00
|
|
|
virtual ~IMessage(){};
|
2018-09-17 15:32:37 +00:00
|
|
|
|
2018-06-22 13:59:28 +00:00
|
|
|
virtual bool
|
2018-06-26 16:23:43 +00:00
|
|
|
HandleMessage(IMessageHandler* h, llarp_router* r) const = 0;
|
2018-06-22 13:59:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct InboundMessageParser
|
|
|
|
{
|
|
|
|
InboundMessageParser();
|
|
|
|
bool
|
2018-06-26 16:23:43 +00:00
|
|
|
ParseMessageBuffer(llarp_buffer_t buf, IMessageHandler* handler,
|
2018-07-18 20:58:16 +00:00
|
|
|
const PathID_t& from, llarp_router* r);
|
2018-06-22 13:59:28 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
static bool
|
|
|
|
OnKey(dict_reader* r, llarp_buffer_t* key);
|
|
|
|
bool firstKey;
|
2018-07-17 06:17:13 +00:00
|
|
|
char key;
|
2018-06-22 13:59:28 +00:00
|
|
|
dict_reader reader;
|
|
|
|
IMessage* msg;
|
|
|
|
};
|
|
|
|
} // namespace routing
|
|
|
|
} // namespace llarp
|
|
|
|
|
2018-09-17 15:32:37 +00:00
|
|
|
#endif
|