2021-03-09 22:24:35 +00:00
|
|
|
#pragma once
|
2018-05-25 17:52:10 +00:00
|
|
|
|
2023-08-29 14:26:59 +00:00
|
|
|
#include "common.hpp"
|
|
|
|
|
2023-10-24 13:18:03 +00:00
|
|
|
#include <llarp/path/path_types.hpp>
|
2021-03-09 22:24:35 +00:00
|
|
|
#include <llarp/router_id.hpp>
|
|
|
|
#include <llarp/util/bencode.hpp>
|
2018-05-25 17:52:10 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
2023-09-19 20:09:18 +00:00
|
|
|
namespace link
|
|
|
|
{
|
|
|
|
struct Connection;
|
|
|
|
}
|
|
|
|
|
2023-09-15 14:55:32 +00:00
|
|
|
struct Router;
|
2018-06-01 14:08:54 +00:00
|
|
|
|
|
|
|
/// parsed link layer message
|
2023-08-29 14:26:59 +00:00
|
|
|
struct AbstractLinkMessage : private AbstractSerializable
|
2018-05-25 17:52:10 +00:00
|
|
|
{
|
2023-09-19 20:09:18 +00:00
|
|
|
std::shared_ptr<link::Connection> conn;
|
2019-10-25 21:13:11 +00:00
|
|
|
PathID_t pathid;
|
|
|
|
|
2023-09-19 20:09:18 +00:00
|
|
|
uint64_t version = llarp::constants::proto_version;
|
|
|
|
|
2023-08-29 14:26:59 +00:00
|
|
|
AbstractLinkMessage() = default;
|
2018-09-02 18:25:42 +00:00
|
|
|
|
2023-08-29 14:26:59 +00:00
|
|
|
virtual ~AbstractLinkMessage() = default;
|
2018-06-01 14:08:54 +00:00
|
|
|
|
2023-08-29 14:26:59 +00:00
|
|
|
std::string
|
|
|
|
bt_encode() const override = 0;
|
2019-05-24 02:01:36 +00:00
|
|
|
|
|
|
|
virtual bool
|
2023-09-15 14:55:32 +00:00
|
|
|
handle_message(Router* router) const = 0;
|
2019-05-24 02:01:36 +00:00
|
|
|
|
2018-06-01 14:08:54 +00:00
|
|
|
virtual bool
|
2023-08-29 14:26:59 +00:00
|
|
|
decode_key(const llarp_buffer_t& key, llarp_buffer_t* buf) = 0;
|
2018-05-25 17:52:10 +00:00
|
|
|
|
2018-12-20 16:49:05 +00:00
|
|
|
virtual void
|
2023-08-29 14:26:59 +00:00
|
|
|
clear() = 0;
|
2019-03-26 20:04:41 +00:00
|
|
|
|
|
|
|
// the name of this kind of message
|
|
|
|
virtual const char*
|
2023-08-29 14:26:59 +00:00
|
|
|
name() const = 0;
|
2020-01-17 16:33:37 +00:00
|
|
|
|
|
|
|
/// get message prority, higher value means more important
|
|
|
|
virtual uint16_t
|
2023-08-29 14:26:59 +00:00
|
|
|
priority() const
|
2020-01-17 16:33:37 +00:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2023-08-29 14:26:59 +00:00
|
|
|
|
|
|
|
// methods we do not want to inherit onwards from AbstractSerializable
|
|
|
|
void
|
|
|
|
bt_encode(oxenc::bt_dict_producer&) const final
|
|
|
|
{
|
|
|
|
throw std::runtime_error{
|
|
|
|
"Error: Link messages should not encode directly to a bt list producer!"};
|
|
|
|
}
|
2018-05-25 17:52:10 +00:00
|
|
|
};
|
2018-06-23 00:00:44 +00:00
|
|
|
} // namespace llarp
|