Browse Source

moved sending acks to SSUData

pull/72/head
orignal 11 years ago
parent
commit
165a079928
  1. 16
      SSU.cpp
  2. 1
      SSU.h
  3. 19
      SSUData.cpp
  4. 4
      SSUData.h

16
SSU.cpp

@ -807,22 +807,6 @@ namespace ssu @@ -807,22 +807,6 @@ namespace ssu
Send (buf, 80);
}
void SSUSession::SendMsgAck (uint32_t msgID)
{
uint8_t buf[48 + 18]; // actual length is 44 = 37 + 7 but pad it to multiple of 16
uint8_t * payload = buf + sizeof (SSUHeader);
*payload = DATA_FLAG_EXPLICIT_ACKS_INCLUDED; // flag
payload++;
*payload = 1; // number of ACKs
payload++;
*(uint32_t *)(payload) = htobe32 (msgID); // msgID
payload += 4;
*payload = 0; // number of fragments
// encrypt message with session key
FillHeaderAndEncrypt (PAYLOAD_TYPE_DATA, buf, 48);
Send (buf, 48);
}
void SSUSession::SendSesionDestroyed ()
{

1
SSU.h

@ -97,7 +97,6 @@ namespace ssu @@ -97,7 +97,6 @@ namespace ssu
void ProcessPeerTest (uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint);
void SendPeerTest (uint32_t nonce, uint32_t address, uint16_t port, uint8_t * introKey); // Charlie to Alice
void ProcessData (uint8_t * buf, size_t len);
void SendMsgAck (uint32_t msgID);
void SendSesionDestroyed ();
void Send (uint8_t type, const uint8_t * payload, size_t len); // with session key
void Send (const uint8_t * buf, size_t size);

19
SSUData.cpp

@ -113,7 +113,7 @@ namespace ssu @@ -113,7 +113,7 @@ namespace ssu
m_IncomleteMessages[msgID] = new IncompleteMessage (msg);
if (isLast)
{
m_Session.SendMsgAck (msgID);
SendMsgAck (msgID);
msg->FromSSU (msgID);
if (m_Session.GetState () == eSessionStateEstablished)
i2p::HandleI2NPMessage (msg);
@ -183,6 +183,23 @@ namespace ssu @@ -183,6 +183,23 @@ namespace ssu
}
DeleteI2NPMessage (msg);
}
void SSUData::SendMsgAck (uint32_t msgID)
{
uint8_t buf[48 + 18]; // actual length is 44 = 37 + 7 but pad it to multiple of 16
uint8_t * payload = buf + sizeof (SSUHeader);
*payload = DATA_FLAG_EXPLICIT_ACKS_INCLUDED; // flag
payload++;
*payload = 1; // number of ACKs
payload++;
*(uint32_t *)(payload) = htobe32 (msgID); // msgID
payload += 4;
*payload = 0; // number of fragments
// encrypt message with session key
m_Session.FillHeaderAndEncrypt (PAYLOAD_TYPE_DATA, buf, 48);
m_Session.Send (buf, 48);
}
}
}

4
SSUData.h

@ -29,6 +29,10 @@ namespace ssu @@ -29,6 +29,10 @@ namespace ssu
void ProcessMessage (uint8_t * buf, size_t len);
void Send (i2p::I2NPMessage * msg);
private:
void SendMsgAck (uint32_t msgID);
private:
struct IncompleteMessage

Loading…
Cancel
Save