process session created after decryption with intro key

This commit is contained in:
orignal 2014-04-07 16:53:28 -04:00
parent 64f195868e
commit be563dcbd1

23
SSU.cpp
View File

@ -61,13 +61,10 @@ namespace ssu
break; break;
// establishing or testing // establishing or testing
case eSessionStateUnknown: case eSessionStateUnknown:
case eSessionStateRequestSent:
// we must use intro key // we must use intro key
ProcessIntroKeyMessage (buf, len, senderEndpoint); ProcessIntroKeyMessage (buf, len, senderEndpoint);
break; break;
case eSessionStateRequestSent:
// session created
ProcessSessionCreated (buf, len);
break;
case eSessionStateCreatedSent: case eSessionStateCreatedSent:
// session confirmed // session confirmed
ProcessSessionConfirmed (buf, len); ProcessSessionConfirmed (buf, len);
@ -147,7 +144,10 @@ namespace ssu
switch (header->GetPayloadType ()) switch (header->GetPayloadType ())
{ {
case PAYLOAD_TYPE_SESSION_REQUEST: case PAYLOAD_TYPE_SESSION_REQUEST:
ProcessSessionRequest (buf + sizeof (SSUHeader), len - sizeof (SSUHeader), senderEndpoint); ProcessSessionRequest (buf, len, senderEndpoint);
break;
case PAYLOAD_TYPE_SESSION_CREATED:
ProcessSessionCreated (buf, len);
break; break;
case PAYLOAD_TYPE_PEER_TEST: case PAYLOAD_TYPE_PEER_TEST:
// TODO // TODO
@ -162,27 +162,17 @@ namespace ssu
m_State = eSessionStateRequestReceived; m_State = eSessionStateRequestReceived;
LogPrint ("Session request received"); LogPrint ("Session request received");
m_RemoteEndpoint = senderEndpoint; m_RemoteEndpoint = senderEndpoint;
SendSessionCreated (buf); SendSessionCreated (buf + sizeof (SSUHeader));
} }
void SSUSession::ProcessSessionCreated (uint8_t * buf, size_t len) void SSUSession::ProcessSessionCreated (uint8_t * buf, size_t len)
{ {
LogPrint ("Process session created");
if (!m_RemoteRouter) if (!m_RemoteRouter)
{ {
LogPrint ("Unsolicited session created message"); LogPrint ("Unsolicited session created message");
return; return;
} }
// use remote intro key
if (ProcessIntroKeyEncryptedMessage (buf, len))
{
SSUHeader * header = (SSUHeader *)buf;
if (header->GetPayloadType () != PAYLOAD_TYPE_SESSION_CONFIRMED)
{
LogPrint ("Unexpected payload type ", header->GetPayloadType ());
return;
}
m_State = eSessionStateCreatedReceived; m_State = eSessionStateCreatedReceived;
LogPrint ("Session created received"); LogPrint ("Session created received");
m_Timer.cancel (); // connect timer m_Timer.cancel (); // connect timer
@ -219,7 +209,6 @@ namespace ssu
SendSessionConfirmed (y, ourAddress, relayTag); SendSessionConfirmed (y, ourAddress, relayTag);
} }
}
void SSUSession::ProcessSessionConfirmed (uint8_t * buf, size_t len) void SSUSession::ProcessSessionConfirmed (uint8_t * buf, size_t len)
{ {