lokinet/llarp/messages/link_message.hpp

55 lines
1.0 KiB
C++
Raw Normal View History

#ifndef LLARP_LINK_MESSAGE_HPP
#define LLARP_LINK_MESSAGE_HPP
2018-12-12 01:32:10 +00:00
#include <link/session.hpp>
#include <router_id.hpp>
#include <util/bencode.hpp>
#include <path/path_types.hpp>
#include <vector>
namespace llarp
{
struct ILinkSession;
struct AbstractRouter;
2018-06-01 14:08:54 +00:00
/// parsed link layer message
2019-05-24 02:01:36 +00:00
struct ILinkMessage
{
/// who did this message come from or is going to
2018-12-20 16:49:05 +00:00
ILinkSession* session = nullptr;
2019-05-24 02:01:36 +00:00
uint64_t version = LLARP_PROTO_VERSION;
2018-06-01 14:08:54 +00:00
PathID_t pathid;
2018-12-20 16:49:05 +00:00
ILinkMessage() = default;
2019-06-15 14:55:13 +00:00
virtual ~ILinkMessage() = default;
2018-06-01 14:08:54 +00:00
2019-05-24 02:01:36 +00:00
virtual bool
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) = 0;
bool
BDecode(llarp_buffer_t* buf)
{
return bencode_decode_dict(*this, buf);
}
virtual bool
BEncode(llarp_buffer_t* buf) const = 0;
2018-06-01 14:08:54 +00:00
virtual bool
HandleMessage(AbstractRouter* router) const = 0;
2018-12-20 16:49:05 +00:00
virtual void
Clear() = 0;
2019-03-26 20:04:41 +00:00
// the name of this kind of message
virtual const char*
Name() const = 0;
};
2018-12-20 16:49:05 +00:00
2018-06-23 00:00:44 +00:00
} // namespace llarp
#endif