2018-05-26 18:31:45 +00:00
|
|
|
#ifndef LLARP_RELAY_COMMIT_HPP
|
|
|
|
#define LLARP_RELAY_COMMIT_HPP
|
2018-12-12 02:52:51 +00:00
|
|
|
|
2019-01-14 21:46:07 +00:00
|
|
|
#include <crypto/encrypted_frame.hpp>
|
2019-01-13 16:30:07 +00:00
|
|
|
#include <crypto/types.hpp>
|
2019-01-14 21:46:07 +00:00
|
|
|
#include <messages/link_message.hpp>
|
2019-01-11 01:19:36 +00:00
|
|
|
#include <path/path_types.hpp>
|
2018-12-12 02:52:51 +00:00
|
|
|
#include <pow.hpp>
|
2018-12-12 01:32:10 +00:00
|
|
|
|
2018-09-17 18:43:14 +00:00
|
|
|
#include <array>
|
2019-02-11 14:43:48 +00:00
|
|
|
#include <memory>
|
2019-07-30 23:42:13 +00:00
|
|
|
#include <utility>
|
2018-05-26 18:31:45 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
2018-06-18 22:03:50 +00:00
|
|
|
// forward declare
|
2019-02-11 19:45:42 +00:00
|
|
|
struct AbstractRouter;
|
2018-06-25 15:12:08 +00:00
|
|
|
namespace path
|
|
|
|
{
|
|
|
|
struct PathContext;
|
|
|
|
}
|
2018-06-18 22:03:50 +00:00
|
|
|
|
2018-05-26 18:31:45 +00:00
|
|
|
struct LR_CommitRecord
|
|
|
|
{
|
2018-06-12 11:57:14 +00:00
|
|
|
PubKey commkey;
|
2018-06-18 22:03:50 +00:00
|
|
|
RouterID nextHop;
|
2018-06-12 11:57:14 +00:00
|
|
|
TunnelNonce tunnelNonce;
|
2018-06-22 00:25:30 +00:00
|
|
|
PathID_t txid, rxid;
|
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
std::unique_ptr<RouterContact> nextRC;
|
|
|
|
std::unique_ptr<PoW> work;
|
|
|
|
uint64_t version = 0;
|
2020-02-24 19:40:45 +00:00
|
|
|
llarp_time_t lifetime = 0s;
|
2018-05-26 18:31:45 +00:00
|
|
|
|
|
|
|
bool
|
2020-04-07 18:38:56 +00:00
|
|
|
BDecode(llarp_buffer_t* buf);
|
2018-05-26 18:31:45 +00:00
|
|
|
|
|
|
|
bool
|
2020-04-07 18:38:56 +00:00
|
|
|
BEncode(llarp_buffer_t* buf) const;
|
2018-06-12 12:49:23 +00:00
|
|
|
|
2018-06-21 12:55:02 +00:00
|
|
|
bool
|
2020-04-07 18:38:56 +00:00
|
|
|
operator==(const LR_CommitRecord& other) const;
|
2018-06-21 12:55:02 +00:00
|
|
|
|
2018-06-12 12:49:23 +00:00
|
|
|
private:
|
2019-05-22 00:36:03 +00:00
|
|
|
bool
|
2020-04-07 18:38:56 +00:00
|
|
|
OnKey(llarp_buffer_t* buffer, llarp_buffer_t* key);
|
2018-05-26 18:31:45 +00:00
|
|
|
};
|
|
|
|
|
2018-06-01 14:08:54 +00:00
|
|
|
struct LR_CommitMessage : public ILinkMessage
|
2018-05-26 18:31:45 +00:00
|
|
|
{
|
2020-04-07 18:38:56 +00:00
|
|
|
std::array<EncryptedFrame, 8> frames;
|
2018-05-26 18:31:45 +00:00
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
LR_CommitMessage(std::array<EncryptedFrame, 8> _frames)
|
2019-07-30 23:42:13 +00:00
|
|
|
: ILinkMessage(), frames(std::move(_frames))
|
2019-04-30 12:22:15 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-06-15 14:55:13 +00:00
|
|
|
LR_CommitMessage() = default;
|
2018-06-18 22:03:50 +00:00
|
|
|
|
2019-07-30 23:42:13 +00:00
|
|
|
~LR_CommitMessage() override = default;
|
2018-06-01 14:08:54 +00:00
|
|
|
|
2018-05-26 18:31:45 +00:00
|
|
|
void
|
2019-03-29 01:02:41 +00:00
|
|
|
Clear() override;
|
2018-05-26 18:31:45 +00:00
|
|
|
|
|
|
|
bool
|
2020-04-07 18:38:56 +00:00
|
|
|
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf) override;
|
2018-05-26 18:31:45 +00:00
|
|
|
|
|
|
|
bool
|
2020-04-07 18:38:56 +00:00
|
|
|
BEncode(llarp_buffer_t* buf) const override;
|
2018-06-01 14:08:54 +00:00
|
|
|
|
|
|
|
bool
|
2020-04-07 18:38:56 +00:00
|
|
|
HandleMessage(AbstractRouter* router) const override;
|
2018-06-18 22:03:50 +00:00
|
|
|
|
|
|
|
bool
|
2020-04-07 18:38:56 +00:00
|
|
|
AsyncDecrypt(llarp::path::PathContext* context) const;
|
2019-03-26 20:04:41 +00:00
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
const char*
|
2019-03-26 20:04:41 +00:00
|
|
|
Name() const override
|
|
|
|
{
|
|
|
|
return "RelayCommit";
|
|
|
|
}
|
2020-01-17 16:33:37 +00:00
|
|
|
|
|
|
|
virtual uint16_t
|
|
|
|
Priority() const override
|
|
|
|
{
|
|
|
|
return 5;
|
|
|
|
}
|
2018-05-26 18:31:45 +00:00
|
|
|
};
|
2018-06-18 22:03:50 +00:00
|
|
|
} // namespace llarp
|
2018-05-26 18:31:45 +00:00
|
|
|
|
|
|
|
#endif
|