mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
short I2NP message
This commit is contained in:
parent
5e8dd82b6b
commit
816c415f22
@ -18,13 +18,14 @@ namespace i2p
|
|||||||
|
|
||||||
I2NPMessage * NewI2NPMessage ()
|
I2NPMessage * NewI2NPMessage ()
|
||||||
{
|
{
|
||||||
I2NPMessage * msg = new I2NPMessage;
|
return new I2NPMessageBuffer<I2NP_MAX_MESSAGE_SIZE>();
|
||||||
msg->offset = 2; // reserve 2 bytes for NTCP header, should reserve more for SSU in future
|
|
||||||
msg->len = sizeof (I2NPHeader) + 2;
|
|
||||||
msg->from = nullptr;
|
|
||||||
return msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
I2NPMessage * NewI2NPShortMessage ()
|
||||||
|
{
|
||||||
|
return new I2NPMessageBuffer<I2NP_MAX_SHORT_MESSAGE_SIZE>();
|
||||||
|
}
|
||||||
|
|
||||||
void DeleteI2NPMessage (I2NPMessage * msg)
|
void DeleteI2NPMessage (I2NPMessage * msg)
|
||||||
{
|
{
|
||||||
delete msg;
|
delete msg;
|
||||||
|
@ -102,12 +102,15 @@ namespace tunnel
|
|||||||
}
|
}
|
||||||
|
|
||||||
const size_t I2NP_MAX_MESSAGE_SIZE = 32768;
|
const size_t I2NP_MAX_MESSAGE_SIZE = 32768;
|
||||||
|
const size_t I2NP_MAX_SHORT_MESSAGE_SIZE = 2400;
|
||||||
struct I2NPMessage
|
struct I2NPMessage
|
||||||
{
|
{
|
||||||
uint8_t buf[I2NP_MAX_MESSAGE_SIZE];
|
uint8_t * buf;
|
||||||
size_t len, offset;
|
size_t len, offset;
|
||||||
i2p::tunnel::InboundTunnel * from;
|
i2p::tunnel::InboundTunnel * from;
|
||||||
|
|
||||||
|
I2NPMessage (): buf (nullptr),len (sizeof (I2NPHeader) + 2), offset(2), from (nullptr) {};
|
||||||
|
// reserve 2 bytes for NTCP header
|
||||||
I2NPHeader * GetHeader () { return (I2NPHeader *)GetBuffer (); };
|
I2NPHeader * GetHeader () { return (I2NPHeader *)GetBuffer (); };
|
||||||
uint8_t * GetPayload () { return GetBuffer () + sizeof(I2NPHeader); };
|
uint8_t * GetPayload () { return GetBuffer () + sizeof(I2NPHeader); };
|
||||||
uint8_t * GetBuffer () { return buf + offset; };
|
uint8_t * GetBuffer () { return buf + offset; };
|
||||||
@ -144,7 +147,16 @@ namespace tunnel
|
|||||||
return be32toh (header.msgID);
|
return be32toh (header.msgID);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<int sz>
|
||||||
|
struct I2NPMessageBuffer: public I2NPMessage
|
||||||
|
{
|
||||||
|
I2NPMessageBuffer () { buf = m_Buffer; };
|
||||||
|
uint8_t m_Buffer[sz];
|
||||||
|
};
|
||||||
|
|
||||||
I2NPMessage * NewI2NPMessage ();
|
I2NPMessage * NewI2NPMessage ();
|
||||||
|
I2NPMessage * NewI2NPShortMessage ();
|
||||||
void DeleteI2NPMessage (I2NPMessage * msg);
|
void DeleteI2NPMessage (I2NPMessage * msg);
|
||||||
void FillI2NPMessageHeader (I2NPMessage * msg, I2NPMessageType msgType, uint32_t replyMsgID = 0);
|
void FillI2NPMessageHeader (I2NPMessage * msg, I2NPMessageType msgType, uint32_t replyMsgID = 0);
|
||||||
void RenewI2NPMessageHeader (I2NPMessage * msg);
|
void RenewI2NPMessageHeader (I2NPMessage * msg);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user