mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-10-29 11:05:43 +00:00
56 lines
1.1 KiB
C++
56 lines
1.1 KiB
C++
#ifndef LLARP_SERVICE_PROTOCOL_HPP
|
|
#define LLARP_SERVICE_PROTOCOL_HPP
|
|
#include <llarp/time.h>
|
|
#include <llarp/bencode.hpp>
|
|
#include <llarp/crypto.hpp>
|
|
#include <vector>
|
|
|
|
namespace llarp
|
|
{
|
|
namespace service
|
|
{
|
|
enum ProtocolType
|
|
{
|
|
eProtocolText = 0,
|
|
eProtocolTraffic = 1
|
|
};
|
|
|
|
struct ProtocolMessage : public llarp::IBEncodeMessage
|
|
{
|
|
ProtocolMessage(ProtocolType t);
|
|
~ProtocolMessage();
|
|
ProtocolType proto;
|
|
llarp_time_t queued = 0;
|
|
std::vector< byte_t > payload;
|
|
llarp::KeyExchangeNonce N;
|
|
|
|
bool
|
|
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val);
|
|
bool
|
|
BEncode(llarp_buffer_t* buf) const;
|
|
|
|
void
|
|
PutBuffer(llarp_buffer_t payload);
|
|
|
|
struct GetTime
|
|
{
|
|
llarp_time_t
|
|
operator()(const ProtocolMessage* msg) const
|
|
{
|
|
return msg->queued;
|
|
}
|
|
};
|
|
|
|
struct PutTime
|
|
{
|
|
void
|
|
operator()(ProtocolMessage* msg, llarp_time_t now) const
|
|
{
|
|
msg->queued = now;
|
|
}
|
|
};
|
|
};
|
|
} // namespace service
|
|
} // namespace llarp
|
|
|
|
#endif |