2018-05-26 18:31:45 +00:00
|
|
|
#ifndef LLARP_RELAY_COMMIT_HPP
|
|
|
|
#define LLARP_RELAY_COMMIT_HPP
|
2018-06-12 11:57:14 +00:00
|
|
|
#include <llarp/crypto.hpp>
|
2018-06-11 13:25:10 +00:00
|
|
|
#include <llarp/encrypted_ack.hpp>
|
2018-05-26 18:31:45 +00:00
|
|
|
#include <llarp/encrypted_frame.hpp>
|
2018-06-01 14:08:54 +00:00
|
|
|
#include <llarp/link_message.hpp>
|
2018-06-10 14:05:48 +00:00
|
|
|
#include <llarp/path_types.hpp>
|
2018-06-18 22:03:50 +00:00
|
|
|
#include <llarp/pow.hpp>
|
2018-05-26 18:31:45 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
2018-06-18 22:03:50 +00:00
|
|
|
// forward declare
|
|
|
|
struct PathContext;
|
|
|
|
|
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-18 22:03:50 +00:00
|
|
|
PathID_t pathid;
|
|
|
|
PoW *work = nullptr;
|
2018-05-26 18:31:45 +00:00
|
|
|
uint64_t version;
|
|
|
|
|
|
|
|
bool
|
|
|
|
BDecode(llarp_buffer_t *buf);
|
|
|
|
|
|
|
|
bool
|
2018-06-10 14:05:48 +00:00
|
|
|
BEncode(llarp_buffer_t *buf) const;
|
2018-06-12 12:49:23 +00:00
|
|
|
|
2018-06-18 22:03:50 +00:00
|
|
|
~LR_CommitRecord();
|
|
|
|
|
2018-06-12 12:49:23 +00:00
|
|
|
private:
|
|
|
|
static bool
|
|
|
|
OnKey(dict_reader *r, llarp_buffer_t *buf);
|
2018-05-26 18:31:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct LR_AcceptRecord
|
|
|
|
{
|
2018-06-18 22:03:50 +00:00
|
|
|
RouterID upstream;
|
|
|
|
RouterID downstream;
|
|
|
|
PathID_t pathid;
|
|
|
|
uint64_t version = LLARP_PROTO_VERSION;
|
2018-05-26 18:31:45 +00:00
|
|
|
|
|
|
|
bool
|
2018-06-10 14:05:48 +00:00
|
|
|
DecodeKey(llarp_buffer_t key, llarp_buffer_t *buf);
|
2018-05-26 18:31:45 +00:00
|
|
|
|
|
|
|
bool
|
2018-06-10 14:05:48 +00:00
|
|
|
BEncode(llarp_buffer_t *buf) const;
|
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
|
|
|
{
|
|
|
|
std::vector< EncryptedFrame > frames;
|
|
|
|
uint64_t version;
|
|
|
|
|
2018-06-12 16:45:12 +00:00
|
|
|
LR_CommitMessage() : ILinkMessage()
|
|
|
|
{
|
|
|
|
}
|
2018-06-18 22:03:50 +00:00
|
|
|
|
2018-06-01 14:08:54 +00:00
|
|
|
LR_CommitMessage(const RouterID &from) : ILinkMessage(from)
|
|
|
|
{
|
|
|
|
}
|
2018-06-12 12:49:23 +00:00
|
|
|
|
2018-06-01 14:08:54 +00:00
|
|
|
~LR_CommitMessage();
|
|
|
|
|
2018-05-26 18:31:45 +00:00
|
|
|
void
|
|
|
|
Clear();
|
|
|
|
|
|
|
|
bool
|
2018-06-01 14:08:54 +00:00
|
|
|
DecodeKey(llarp_buffer_t key, llarp_buffer_t *buf);
|
2018-05-26 18:31:45 +00:00
|
|
|
|
|
|
|
bool
|
2018-06-01 14:08:54 +00:00
|
|
|
BEncode(llarp_buffer_t *buf) const;
|
|
|
|
|
|
|
|
bool
|
|
|
|
HandleMessage(llarp_router *router) const;
|
2018-06-18 22:03:50 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
AsyncDecrypt(PathContext *context) const;
|
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
|