i2pd/TunnelBase.h

53 lines
1.1 KiB
C
Raw Normal View History

2013-11-10 23:19:49 +00:00
#ifndef TUNNEL_BASE_H__
#define TUNNEL_BASE_H__
#include <inttypes.h>
2014-01-04 03:56:28 +00:00
#include "Timestamp.h"
#include "I2NPProtocol.h"
2013-11-10 23:19:49 +00:00
namespace i2p
{
namespace tunnel
{
const size_t TUNNEL_DATA_MSG_SIZE = 1028;
2013-12-10 13:10:49 +00:00
const size_t TUNNEL_DATA_ENCRYPTED_SIZE = 1008;
const size_t TUNNEL_DATA_MAX_PAYLOAD_SIZE = 1003;
2013-11-10 23:19:49 +00:00
enum TunnelDeliveryType
{
eDeliveryTypeLocal = 0,
eDeliveryTypeTunnel = 1,
eDeliveryTypeRouter = 2
};
struct TunnelMessageBlock
{
TunnelDeliveryType deliveryType;
uint32_t tunnelID;
uint8_t hash[32];
I2NPMessage * data;
};
class TunnelBase
{
public:
2014-01-04 03:56:28 +00:00
TunnelBase (): m_CreationTime (i2p::util::GetSecondsSinceEpoch ()) {};
2013-12-10 13:10:49 +00:00
virtual ~TunnelBase () {};
virtual void EncryptTunnelMsg (I2NPMessage * tunnelMsg) = 0;
virtual uint32_t GetNextTunnelID () const = 0;
2013-12-10 13:10:49 +00:00
virtual const i2p::data::IdentHash& GetNextIdentHash () const = 0;
2014-01-04 03:56:28 +00:00
virtual uint32_t GetTunnelID () const = 0; // as known at our side
uint32_t GetCreationTime () const { return m_CreationTime; };
void SetCreationTime (uint32_t t) { m_CreationTime = t; };
private:
uint32_t m_CreationTime; // seconds since epoch
};
2013-11-10 23:19:49 +00:00
}
}
#endif