2013-12-13 06:36:24 +04:00
|
|
|
#ifndef STREAMING_H__
|
|
|
|
#define STREAMING_H__
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
2013-12-20 06:19:44 +04:00
|
|
|
#include <map>
|
2013-12-31 05:46:33 +04:00
|
|
|
#include "Identity.h"
|
2013-12-20 06:19:44 +04:00
|
|
|
#include "I2NPProtocol.h"
|
2013-12-13 06:36:24 +04:00
|
|
|
|
|
|
|
namespace i2p
|
|
|
|
{
|
|
|
|
namespace stream
|
|
|
|
{
|
|
|
|
const uint16_t PACKET_FLAG_SYNCHRONIZE = 0x0001;
|
|
|
|
const uint16_t PACKET_FLAG_CLOSE = 0x0002;
|
|
|
|
const uint16_t PACKET_FLAG_RESET = 0x0004;
|
|
|
|
const uint16_t PACKET_FLAG_SIGNATURE_INCLUDED = 0x0008;
|
|
|
|
const uint16_t PACKET_FLAG_SIGNATURE_REQUESTED = 0x0010;
|
|
|
|
const uint16_t PACKET_FLAG_FROM_INCLUDED = 0x0020;
|
|
|
|
const uint16_t PACKET_FLAG_DELAY_REQUESTED = 0x0040;
|
|
|
|
const uint16_t PACKET_FLAG_MAX_PACKET_SIZE_INCLUDED = 0x0080;
|
|
|
|
const uint16_t PACKET_FLAG_PROFILE_INTERACTIVE = 0x0100;
|
|
|
|
const uint16_t PACKET_FLAG_ECHO = 0x0200;
|
|
|
|
const uint16_t PACKET_FLAG_NO_ACK = 0x0400;
|
|
|
|
|
2013-12-31 05:46:33 +04:00
|
|
|
class StreamingDestination;
|
2013-12-20 06:19:44 +04:00
|
|
|
class Stream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2013-12-31 05:46:33 +04:00
|
|
|
Stream (StreamingDestination * local, const i2p::data::IdentHash& remote);
|
2013-12-20 06:19:44 +04:00
|
|
|
uint32_t GetSendStreamID () const { return m_SendStreamID; };
|
|
|
|
uint32_t GetRecvStreamID () const { return m_RecvStreamID; };
|
|
|
|
|
|
|
|
void HandleNextPacket (const uint8_t * buf, size_t len);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
uint32_t m_SendStreamID, m_RecvStreamID;
|
2013-12-31 05:46:33 +04:00
|
|
|
StreamingDestination * m_LocalDestination;
|
2013-12-20 06:19:44 +04:00
|
|
|
};
|
|
|
|
|
2013-12-13 06:36:24 +04:00
|
|
|
class StreamingDestination
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2013-12-31 05:46:33 +04:00
|
|
|
StreamingDestination ();
|
|
|
|
|
|
|
|
const i2p::data::Keys GetKeys () const { return m_Keys; };
|
|
|
|
I2NPMessage * CreateLeaseSet () const;
|
|
|
|
|
2013-12-20 06:19:44 +04:00
|
|
|
Stream * CreateNewStream (const i2p::data::IdentHash& destination);
|
2013-12-13 06:36:24 +04:00
|
|
|
void HandleNextPacket (const uint8_t * buf, size_t len);
|
2013-12-31 05:46:33 +04:00
|
|
|
|
2013-12-20 06:19:44 +04:00
|
|
|
private:
|
|
|
|
|
|
|
|
std::map<uint32_t, Stream *> m_Streams;
|
2013-12-31 05:46:33 +04:00
|
|
|
i2p::data::Keys m_Keys;
|
|
|
|
i2p::data::Identity m_Identity;
|
|
|
|
i2p::data::IdentHash m_IdentHash;
|
2013-12-20 06:19:44 +04:00
|
|
|
};
|
|
|
|
|
2013-12-13 06:36:24 +04:00
|
|
|
// assuming data is I2CP message
|
|
|
|
void HandleDataMessage (i2p::data::IdentHash * destination, const uint8_t * buf, size_t len);
|
2013-12-20 06:19:44 +04:00
|
|
|
I2NPMessage * CreateDataMessage (Stream * s, uint8_t * payload, size_t len);
|
2013-12-13 06:36:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|