mirror of https://github.com/oxen-io/lokinet
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1005 B
C++
49 lines
1005 B
C++
6 years ago
|
#ifndef LLARP_ROUTING_MESSAGE_HPP
|
||
|
#define LLARP_ROUTING_MESSAGE_HPP
|
||
|
|
||
|
#include <llarp/buffer.h>
|
||
6 years ago
|
#include <llarp/bencode.hpp>
|
||
6 years ago
|
#include <llarp/path_types.hpp>
|
||
|
|
||
|
namespace llarp
|
||
|
{
|
||
6 years ago
|
struct Router;
|
||
6 years ago
|
namespace routing
|
||
|
{
|
||
|
struct IMessageHandler;
|
||
|
|
||
6 years ago
|
struct IMessage : public llarp::IBEncodeMessage
|
||
6 years ago
|
{
|
||
|
llarp::PathID_t from;
|
||
6 years ago
|
uint64_t S = 0;
|
||
6 years ago
|
|
||
|
IMessage() : llarp::IBEncodeMessage()
|
||
|
{
|
||
|
}
|
||
|
|
||
6 years ago
|
virtual ~IMessage(){};
|
||
6 years ago
|
|
||
6 years ago
|
virtual bool
|
||
6 years ago
|
HandleMessage(IMessageHandler* h, llarp::Router* r) const = 0;
|
||
6 years ago
|
};
|
||
|
|
||
|
struct InboundMessageParser
|
||
|
{
|
||
|
InboundMessageParser();
|
||
|
bool
|
||
6 years ago
|
ParseMessageBuffer(llarp_buffer_t buf, IMessageHandler* handler,
|
||
6 years ago
|
const PathID_t& from, llarp::Router* r);
|
||
6 years ago
|
|
||
|
private:
|
||
|
static bool
|
||
|
OnKey(dict_reader* r, llarp_buffer_t* key);
|
||
|
bool firstKey;
|
||
6 years ago
|
char key;
|
||
6 years ago
|
dict_reader reader;
|
||
6 years ago
|
std::unique_ptr< IMessage > msg;
|
||
6 years ago
|
};
|
||
|
} // namespace routing
|
||
|
} // namespace llarp
|
||
|
|
||
6 years ago
|
#endif
|