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.
lokinet/llarp/messages/link_message.hpp

64 lines
1.3 KiB
C++

#pragma once
10 months ago
#include "common.hpp"
#include <llarp/path/path_types.hpp>
#include <llarp/router_id.hpp>
#include <llarp/util/bencode.hpp>
#include <vector>
namespace llarp
{
namespace link
{
struct Connection;
}
struct Router;
/// parsed link layer message
10 months ago
struct AbstractLinkMessage : private AbstractSerializable
{
std::shared_ptr<link::Connection> conn;
PathID_t pathid;
uint64_t version = llarp::constants::proto_version;
10 months ago
AbstractLinkMessage() = default;
10 months ago
virtual ~AbstractLinkMessage() = default;
10 months ago
std::string
bt_encode() const override = 0;
virtual bool
handle_message(Router* router) const = 0;
virtual bool
10 months ago
decode_key(const llarp_buffer_t& key, llarp_buffer_t* buf) = 0;
virtual void
10 months ago
clear() = 0;
5 years ago
// the name of this kind of message
virtual const char*
10 months ago
name() const = 0;
/// get message prority, higher value means more important
virtual uint16_t
10 months ago
priority() const
{
return 1;
}
10 months ago
// 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!"};
}
};
6 years ago
} // namespace llarp