2018-11-12 16:43:40 +00:00
|
|
|
#ifndef LLARP_MESSAGES_EXIT_HPP
|
|
|
|
#define LLARP_MESSAGES_EXIT_HPP
|
2019-01-13 14:00:50 +00:00
|
|
|
|
2019-01-13 16:30:07 +00:00
|
|
|
#include <crypto/types.hpp>
|
2018-12-12 01:06:46 +00:00
|
|
|
#include <exit/policy.hpp>
|
2018-12-12 02:04:32 +00:00
|
|
|
#include <routing/message.hpp>
|
2018-12-12 01:06:46 +00:00
|
|
|
|
2018-11-12 16:43:40 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
2019-01-13 16:30:07 +00:00
|
|
|
struct Crypto;
|
2018-11-12 16:43:40 +00:00
|
|
|
namespace routing
|
|
|
|
{
|
|
|
|
struct ObtainExitMessage final : public IMessage
|
|
|
|
{
|
|
|
|
std::vector< llarp::exit::Policy > B;
|
|
|
|
uint64_t E;
|
|
|
|
llarp::PubKey I;
|
|
|
|
uint64_t T;
|
|
|
|
std::vector< llarp::exit::Policy > W;
|
|
|
|
llarp_time_t X;
|
|
|
|
llarp::Signature Z;
|
|
|
|
|
2019-01-02 01:04:04 +00:00
|
|
|
ObtainExitMessage() : IMessage(), E(0), T(0), X(0)
|
2018-11-12 16:43:40 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~ObtainExitMessage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-12-27 14:32:37 +00:00
|
|
|
void
|
2019-01-02 01:04:04 +00:00
|
|
|
Clear() override
|
2018-12-27 14:32:37 +00:00
|
|
|
{
|
|
|
|
B.clear();
|
2019-01-07 12:27:29 +00:00
|
|
|
E = 0;
|
|
|
|
I.Zero();
|
|
|
|
T = 0;
|
2018-12-27 14:32:37 +00:00
|
|
|
W.clear();
|
2019-01-07 12:27:29 +00:00
|
|
|
X = 0;
|
|
|
|
Z.Zero();
|
2018-12-27 14:32:37 +00:00
|
|
|
}
|
|
|
|
|
2018-11-12 16:43:40 +00:00
|
|
|
/// populates I and signs
|
|
|
|
bool
|
2018-12-11 00:53:11 +00:00
|
|
|
Sign(llarp::Crypto* c, const llarp::SecretKey& sk);
|
2018-11-12 16:43:40 +00:00
|
|
|
|
|
|
|
bool
|
2018-12-11 00:53:11 +00:00
|
|
|
Verify(llarp::Crypto* c) const;
|
2018-11-12 16:43:40 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
BEncode(llarp_buffer_t* buf) const override;
|
|
|
|
|
|
|
|
bool
|
|
|
|
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
|
|
|
|
|
|
|
|
bool
|
2018-12-10 16:26:46 +00:00
|
|
|
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
|
2018-11-12 16:43:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct GrantExitMessage final : public IMessage
|
|
|
|
{
|
2018-11-14 18:02:27 +00:00
|
|
|
using Nonce_t = llarp::AlignedBuffer< 16 >;
|
2018-11-14 12:23:08 +00:00
|
|
|
uint64_t T;
|
2018-11-14 18:02:27 +00:00
|
|
|
Nonce_t Y;
|
|
|
|
llarp::Signature Z;
|
2018-11-12 16:43:40 +00:00
|
|
|
GrantExitMessage() : IMessage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~GrantExitMessage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-11-14 18:02:27 +00:00
|
|
|
GrantExitMessage&
|
|
|
|
operator=(const GrantExitMessage& other);
|
|
|
|
|
2018-11-12 16:43:40 +00:00
|
|
|
bool
|
|
|
|
BEncode(llarp_buffer_t* buf) const override;
|
|
|
|
|
2018-11-14 18:02:27 +00:00
|
|
|
bool
|
2018-12-11 00:53:11 +00:00
|
|
|
Sign(llarp::Crypto* c, const llarp::SecretKey& sk);
|
2018-11-14 18:02:27 +00:00
|
|
|
|
|
|
|
bool
|
2018-12-11 00:53:11 +00:00
|
|
|
Verify(llarp::Crypto* c, const llarp::PubKey& pk) const;
|
2018-11-14 18:02:27 +00:00
|
|
|
|
2018-11-12 16:43:40 +00:00
|
|
|
bool
|
|
|
|
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
|
|
|
|
|
|
|
|
bool
|
2018-12-10 16:26:46 +00:00
|
|
|
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
|
2018-12-27 14:32:37 +00:00
|
|
|
|
2019-01-02 01:04:04 +00:00
|
|
|
void
|
|
|
|
Clear() override
|
|
|
|
{
|
2019-01-07 12:27:29 +00:00
|
|
|
T = 0;
|
|
|
|
Y.Zero();
|
|
|
|
Z.Zero();
|
2019-01-02 01:04:04 +00:00
|
|
|
}
|
2018-11-12 16:43:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct RejectExitMessage final : public IMessage
|
|
|
|
{
|
2018-11-14 18:02:27 +00:00
|
|
|
using Nonce_t = llarp::AlignedBuffer< 16 >;
|
2018-11-14 12:23:08 +00:00
|
|
|
uint64_t B;
|
|
|
|
std::vector< llarp::exit::Policy > R;
|
|
|
|
uint64_t T;
|
2018-11-14 18:02:27 +00:00
|
|
|
Nonce_t Y;
|
|
|
|
llarp::Signature Z;
|
2018-11-14 12:23:08 +00:00
|
|
|
|
2018-11-12 16:43:40 +00:00
|
|
|
RejectExitMessage() : IMessage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~RejectExitMessage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-01-02 01:04:04 +00:00
|
|
|
void
|
2018-12-27 14:32:37 +00:00
|
|
|
Clear() override
|
|
|
|
{
|
2019-01-07 12:27:29 +00:00
|
|
|
B = 0;
|
2018-12-27 14:32:37 +00:00
|
|
|
R.clear();
|
2019-01-07 12:27:29 +00:00
|
|
|
T = 0;
|
|
|
|
Y.Zero();
|
|
|
|
Z.Zero();
|
2018-12-27 14:32:37 +00:00
|
|
|
}
|
|
|
|
|
2018-11-14 18:02:27 +00:00
|
|
|
RejectExitMessage&
|
|
|
|
operator=(const RejectExitMessage& other);
|
|
|
|
|
|
|
|
bool
|
2018-12-11 00:53:11 +00:00
|
|
|
Sign(llarp::Crypto* c, const llarp::SecretKey& sk);
|
2018-11-14 18:02:27 +00:00
|
|
|
|
|
|
|
bool
|
2018-12-11 00:53:11 +00:00
|
|
|
Verify(llarp::Crypto* c, const llarp::PubKey& pk) const;
|
2018-11-14 18:02:27 +00:00
|
|
|
|
2018-11-12 16:43:40 +00:00
|
|
|
bool
|
|
|
|
BEncode(llarp_buffer_t* buf) const override;
|
|
|
|
|
|
|
|
bool
|
|
|
|
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
|
|
|
|
|
|
|
|
bool
|
2018-12-10 16:26:46 +00:00
|
|
|
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
|
2018-11-12 16:43:40 +00:00
|
|
|
};
|
|
|
|
|
2018-11-14 12:23:08 +00:00
|
|
|
struct UpdateExitVerifyMessage final : public IMessage
|
|
|
|
{
|
2018-11-14 18:02:27 +00:00
|
|
|
using Nonce_t = llarp::AlignedBuffer< 16 >;
|
2018-11-14 12:23:08 +00:00
|
|
|
uint64_t T;
|
2018-11-14 18:02:27 +00:00
|
|
|
Nonce_t Y;
|
|
|
|
llarp::Signature Z;
|
2018-11-14 12:23:08 +00:00
|
|
|
|
|
|
|
UpdateExitVerifyMessage() : IMessage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~UpdateExitVerifyMessage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-01-02 01:04:04 +00:00
|
|
|
void
|
|
|
|
Clear() override
|
|
|
|
{
|
2019-01-07 12:27:29 +00:00
|
|
|
T = 0;
|
|
|
|
Y.Zero();
|
|
|
|
Z.Zero();
|
2019-01-02 01:04:04 +00:00
|
|
|
}
|
2018-12-27 14:32:37 +00:00
|
|
|
|
2018-11-14 18:02:27 +00:00
|
|
|
UpdateExitVerifyMessage&
|
|
|
|
operator=(const UpdateExitVerifyMessage& other);
|
|
|
|
|
|
|
|
bool
|
2018-12-11 00:53:11 +00:00
|
|
|
Sign(llarp::Crypto* c, const llarp::SecretKey& sk);
|
2018-11-14 18:02:27 +00:00
|
|
|
|
|
|
|
bool
|
2018-12-11 00:53:11 +00:00
|
|
|
Verify(llarp::Crypto* c, const llarp::PubKey& pk) const;
|
2018-11-14 18:02:27 +00:00
|
|
|
|
2018-11-14 12:23:08 +00:00
|
|
|
bool
|
|
|
|
BEncode(llarp_buffer_t* buf) const override;
|
|
|
|
|
|
|
|
bool
|
|
|
|
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
|
|
|
|
|
|
|
|
bool
|
2018-12-10 16:26:46 +00:00
|
|
|
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
|
2018-11-14 12:23:08 +00:00
|
|
|
};
|
|
|
|
|
2018-11-12 16:43:40 +00:00
|
|
|
struct UpdateExitMessage final : public IMessage
|
|
|
|
{
|
2018-11-14 18:02:27 +00:00
|
|
|
using Nonce_t = llarp::AlignedBuffer< 16 >;
|
2018-11-14 12:23:08 +00:00
|
|
|
llarp::PathID_t P;
|
|
|
|
uint64_t T;
|
2018-11-14 18:02:27 +00:00
|
|
|
Nonce_t Y;
|
2018-11-14 12:23:08 +00:00
|
|
|
llarp::Signature Z;
|
|
|
|
|
2018-11-12 16:43:40 +00:00
|
|
|
UpdateExitMessage() : IMessage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~UpdateExitMessage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-11-14 12:23:08 +00:00
|
|
|
UpdateExitMessage&
|
|
|
|
operator=(const UpdateExitMessage& other);
|
|
|
|
|
|
|
|
bool
|
2018-12-11 00:53:11 +00:00
|
|
|
Sign(llarp::Crypto* c, const llarp::SecretKey& sk);
|
2018-11-14 12:23:08 +00:00
|
|
|
|
|
|
|
bool
|
2018-12-11 00:53:11 +00:00
|
|
|
Verify(llarp::Crypto* c, const llarp::PubKey& pk) const;
|
2018-11-14 12:23:08 +00:00
|
|
|
|
2018-11-12 16:43:40 +00:00
|
|
|
bool
|
|
|
|
BEncode(llarp_buffer_t* buf) const override;
|
|
|
|
|
|
|
|
bool
|
|
|
|
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
|
|
|
|
|
|
|
|
bool
|
2018-12-10 16:26:46 +00:00
|
|
|
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
|
2018-12-27 14:32:37 +00:00
|
|
|
|
2019-01-02 01:04:04 +00:00
|
|
|
void
|
|
|
|
Clear() override
|
|
|
|
{
|
2019-01-07 12:27:29 +00:00
|
|
|
P.Zero();
|
|
|
|
T = 0;
|
|
|
|
Y.Zero();
|
|
|
|
Z.Zero();
|
2019-01-02 01:04:04 +00:00
|
|
|
}
|
2018-11-12 16:43:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CloseExitMessage final : public IMessage
|
|
|
|
{
|
2018-11-14 18:02:27 +00:00
|
|
|
using Nonce_t = llarp::AlignedBuffer< 16 >;
|
|
|
|
|
|
|
|
Nonce_t Y;
|
|
|
|
llarp::Signature Z;
|
|
|
|
|
2018-11-12 16:43:40 +00:00
|
|
|
CloseExitMessage() : IMessage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~CloseExitMessage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-11-14 18:02:27 +00:00
|
|
|
CloseExitMessage&
|
|
|
|
operator=(const CloseExitMessage& other);
|
|
|
|
|
2018-11-12 16:43:40 +00:00
|
|
|
bool
|
|
|
|
BEncode(llarp_buffer_t* buf) const override;
|
|
|
|
|
|
|
|
bool
|
|
|
|
DecodeKey(llarp_buffer_t key, llarp_buffer_t* buf) override;
|
|
|
|
|
|
|
|
bool
|
2018-12-10 16:26:46 +00:00
|
|
|
HandleMessage(IMessageHandler* h, llarp::Router* r) const override;
|
2018-11-14 18:02:27 +00:00
|
|
|
|
|
|
|
bool
|
2018-12-11 00:53:11 +00:00
|
|
|
Sign(llarp::Crypto* c, const llarp::SecretKey& sk);
|
2018-11-14 18:02:27 +00:00
|
|
|
|
|
|
|
bool
|
2018-12-11 00:53:11 +00:00
|
|
|
Verify(llarp::Crypto* c, const llarp::PubKey& pk) const;
|
2019-01-02 01:04:04 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
Clear() override
|
|
|
|
{
|
2019-01-07 12:27:29 +00:00
|
|
|
Y.Zero();
|
|
|
|
Z.Zero();
|
2019-01-02 01:04:04 +00:00
|
|
|
}
|
2018-11-12 16:43:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace routing
|
|
|
|
} // namespace llarp
|
|
|
|
|
2018-12-10 16:26:46 +00:00
|
|
|
#endif
|