|
|
@ -47,6 +47,7 @@ namespace ssu |
|
|
|
{ |
|
|
|
{ |
|
|
|
switch (m_State) |
|
|
|
switch (m_State) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
case eSessionStateConfirmedSent: |
|
|
|
case eSessionStateEstablished: |
|
|
|
case eSessionStateEstablished: |
|
|
|
// most common case
|
|
|
|
// most common case
|
|
|
|
ProcessMessage (buf, len); |
|
|
|
ProcessMessage (buf, len); |
|
|
@ -132,8 +133,6 @@ namespace ssu |
|
|
|
i2p::context.UpdateAddress (ourIP.to_string ().c_str ()); |
|
|
|
i2p::context.UpdateAddress (ourIP.to_string ().c_str ()); |
|
|
|
uint32_t relayTag = be32toh (*(uint32_t *)(buf + sizeof (SSUHeader) + 263)); |
|
|
|
uint32_t relayTag = be32toh (*(uint32_t *)(buf + sizeof (SSUHeader) + 263)); |
|
|
|
SendSessionConfirmed (buf + sizeof (SSUHeader), ourAddress, relayTag); |
|
|
|
SendSessionConfirmed (buf + sizeof (SSUHeader), ourAddress, relayTag); |
|
|
|
m_State = eSessionStateEstablished; |
|
|
|
|
|
|
|
Established (); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -147,9 +146,9 @@ namespace ssu |
|
|
|
if ((header->flag >> 4) == PAYLOAD_TYPE_SESSION_CONFIRMED) |
|
|
|
if ((header->flag >> 4) == PAYLOAD_TYPE_SESSION_CONFIRMED) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_State = eSessionStateConfirmedReceived; |
|
|
|
m_State = eSessionStateConfirmedReceived; |
|
|
|
LogPrint ("Session confirmed received"); |
|
|
|
LogPrint ("Session confirmed received"); |
|
|
|
// TODO:
|
|
|
|
|
|
|
|
m_State = eSessionStateEstablished; |
|
|
|
m_State = eSessionStateEstablished; |
|
|
|
|
|
|
|
// TODO: send DeliverStatus
|
|
|
|
Established (); |
|
|
|
Established (); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
@ -374,6 +373,7 @@ namespace ssu |
|
|
|
|
|
|
|
|
|
|
|
void SSUSession::Established () |
|
|
|
void SSUSession::Established () |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
SendI2NPMessage (CreateDatabaseStoreMsg ()); |
|
|
|
if (!m_DelayedMessages.empty ()) |
|
|
|
if (!m_DelayedMessages.empty ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (auto it :m_DelayedMessages) |
|
|
|
for (auto it :m_DelayedMessages) |
|
|
@ -463,11 +463,25 @@ namespace ssu |
|
|
|
m_IncomleteMessages[msgID] = msg; |
|
|
|
m_IncomleteMessages[msgID] = msg; |
|
|
|
if (isLast) |
|
|
|
if (isLast) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
SendMsgAck (msgID); |
|
|
|
if (fragmentNum > 0) |
|
|
|
if (fragmentNum > 0) |
|
|
|
m_IncomleteMessages.erase (msgID); |
|
|
|
m_IncomleteMessages.erase (msgID); |
|
|
|
msg->FromSSU (msgID); |
|
|
|
msg->FromSSU (msgID); |
|
|
|
i2p::HandleI2NPMessage (msg, false); |
|
|
|
if (m_State == eSessionStateEstablished) |
|
|
|
SendMsgAck (msgID); |
|
|
|
i2p::HandleI2NPMessage (msg, false); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// we expect DeliveryStatus
|
|
|
|
|
|
|
|
if (msg->GetHeader ()->typeID == eI2NPDeliveryStatus) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LogPrint ("SSU session established"); |
|
|
|
|
|
|
|
m_State = eSessionStateEstablished; |
|
|
|
|
|
|
|
Established (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
LogPrint ("SSU unexpected message ", (int)msg->GetHeader ()->typeID); |
|
|
|
|
|
|
|
DeleteI2NPMessage (msg); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
buf += fragmentSize; |
|
|
|
buf += fragmentSize; |
|
|
|