send and handle RESET flag

This commit is contained in:
orignal 2015-04-09 21:09:30 -04:00
parent da006a1d6e
commit 11177d37ea
2 changed files with 6 additions and 6 deletions

View File

@ -222,9 +222,9 @@ namespace stream
m_LastReceivedSequenceNumber = receivedSeqn; m_LastReceivedSequenceNumber = receivedSeqn;
if (flags & PACKET_FLAG_CLOSE) if (flags & (PACKET_FLAG_CLOSE | PACKET_FLAG_RESET))
{ {
LogPrint (eLogInfo, "Closed"); LogPrint (eLogInfo, (flags & PACKET_FLAG_RESET) ? "Reset" : "Closed");
m_Status = eStreamStatusReset; m_Status = eStreamStatusReset;
Close (); Close ();
} }
@ -486,7 +486,7 @@ namespace stream
LogPrint (eLogInfo, "Trying to send stream data before closing"); LogPrint (eLogInfo, "Trying to send stream data before closing");
break; break;
case eStreamStatusReset: case eStreamStatusReset:
SendClose (); SendClose (true); // send reset
Terminate (); Terminate ();
m_LocalDestination.DeleteStream (shared_from_this ()); m_LocalDestination.DeleteStream (shared_from_this ());
break; break;
@ -509,7 +509,7 @@ namespace stream
}; };
} }
void Stream::SendClose () void Stream::SendClose (bool reset)
{ {
Packet * p = new Packet (); Packet * p = new Packet ();
uint8_t * packet = p->GetBuffer (); uint8_t * packet = p->GetBuffer ();
@ -525,7 +525,7 @@ namespace stream
packet[size] = 0; packet[size] = 0;
size++; // NACK count size++; // NACK count
size++; // resend delay size++; // resend delay
htobe16buf (packet + size, PACKET_FLAG_CLOSE | PACKET_FLAG_SIGNATURE_INCLUDED); htobe16buf (packet + size, (reset ? PACKET_FLAG_RESET : PACKET_FLAG_CLOSE) | PACKET_FLAG_SIGNATURE_INCLUDED);
size += 2; // flags size += 2; // flags
size_t signatureLen = m_LocalDestination.GetOwner ().GetIdentity ().GetSignatureLen (); size_t signatureLen = m_LocalDestination.GetOwner ().GetIdentity ().GetSignatureLen ();
htobe16buf (packet + size, signatureLen); // signature only htobe16buf (packet + size, signatureLen); // signature only

View File

@ -137,7 +137,7 @@ namespace stream
void SendBuffer (); void SendBuffer ();
void SendQuickAck (); void SendQuickAck ();
void SendClose (); void SendClose (bool reset = false);
bool SendPacket (Packet * packet); bool SendPacket (Packet * packet);
void SendPackets (const std::vector<Packet *>& packets); void SendPackets (const std::vector<Packet *>& packets);