MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / ProcessPacket

Method ProcessPacket

libi2pd/Streaming.cpp:386–423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

384 }
385
386 void Stream::ProcessPacket (Packet * packet)
387 {
388 uint32_t receivedSeqn = packet->GetSeqn ();
389 uint16_t flags = packet->GetFlags ();
390 LogPrint (eLogDebug, "Streaming: Process seqn=", receivedSeqn, ", flags=", flags);
391
392 if (!ProcessOptions (flags, packet))
393 {
394 m_LocalDestination.DeletePacket (packet);
395 Terminate ();
396 return;
397 }
398
399 packet->offset = packet->GetPayload () - packet->buf;
400 if (packet->GetLength () > 0)
401 {
402 m_ReceiveQueue.push (packet);
403 m_ReceiveTimer.cancel ();
404 }
405 else
406 m_LocalDestination.DeletePacket (packet);
407
408 m_LastReceivedSequenceNumber = receivedSeqn;
409
410 if (flags & PACKET_FLAG_RESET)
411 {
412 LogPrint (eLogDebug, "Streaming: closing stream sSID=", m_SendStreamID, ", rSID=", m_RecvStreamID, ": reset flag received in packet #", receivedSeqn);
413 m_Status = eStreamStatusReset;
414 Close ();
415 }
416 else if (flags & PACKET_FLAG_CLOSE)
417 {
418 if (m_Status != eStreamStatusClosed)
419 SendClose ();
420 m_Status = eStreamStatusClosed;
421 Terminate ();
422 }
423 }
424
425 bool Stream::ProcessOptions (uint16_t flags, Packet * packet)
426 {

Callers

nothing calls this directly

Calls 6

LogPrintFunction · 0.85
GetSeqnMethod · 0.80
GetFlagsMethod · 0.80
DeletePacketMethod · 0.80
GetPayloadMethod · 0.45
GetLengthMethod · 0.45

Tested by

no test coverage detected