1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#define MS_CLASS "RTC::SCTP::StreamResetHandler"
// TODO: SCTP: COMMENT
#define MS_LOG_DEV_LEVEL 3
#include "RTC/SCTP/association/StreamResetHandler.hpp"
#include "Logger.hpp"
namespace RTC
{
namespace SCTP
{
/* Instance methods. */
StreamResetHandler::StreamResetHandler(
AssociationListener& associationListener, TCBContext* tcbContext
// TODO: SCTP: Implement
// DataTracker* dataTracker,
// ReassemblyQueue* reassemblyQueue,
// RetransmissionQueue* retransmissionQueue
)
: associationListener(associationListener),
tcbContext(tcbContext),
reconfigTimer(
std::make_unique<BackoffTimerHandle>(
/*listener*/ this,
/*baseTimeoutMs*/ 0,
/*backoffAlgorithm*/ BackoffTimerHandle::BackoffAlgorithm::EXPONENTIAL,
/*maxBackoffTimeoutMs*/ std::nullopt,
/*maxRestarts*/ std::nullopt)),
nextOutgoingReqSeqNbr(tcbContext->GetLocalInitialTsn()),
lastProcessedReqSeqNbr(
this->incomingReconfigRequestSnUnwrapper.Unwrap(tcbContext->GetRemoteInitialTsn() - 1)),
lastProcessedReqResult(ReconfigurationResponseParameter::Result::SUCCESS_NOTHING_TO_DO)
{
MS_TRACE();
}
StreamResetHandler::~StreamResetHandler()
{
MS_TRACE();
}
// TODO
void StreamResetHandler::OnReconfigTimer(uint64_t& baseTimeoutMs, bool& /*stop*/)
{
MS_TRACE();
if (this->currentRequest && this->currentRequest->HasBeenSent())
{
if (this->currentRequest->IsDeferred())
{
// The request was deferred (received "In Progress"). This is not a
// timeout, but just time to retry.
this->currentRequest->SetDeferred(false);
}
else
{
// There is an outstanding request, which timed out while waiting for a
// response.
if (!this->tcbContext->IncrementTxErrorCounter("RECONFIG timeout"))
{
// Timed out. The connection will close after processing the timers.
return;
}
}
}
else
{
// There is no outstanding request, but there is a prepared one. This means
// that the receiver has previously responded "in progress", which resulted
// in retrying the request (but with a new req_seq_nbr) after a while.
}
// TODO: SCTP: Do it.
// ctx_->Send(ctx_->PacketBuilder().Add(MakeReconfigChunk()));
baseTimeoutMs = this->tcbContext->GetCurrentRtoMs();
}
void StreamResetHandler::OnTimer(BackoffTimerHandle* backoffTimer, uint64_t& baseTimeoutMs, bool& stop)
{
MS_TRACE();
if (backoffTimer == this->reconfigTimer.get())
{
OnReconfigTimer(baseTimeoutMs, stop);
}
}
} // namespace SCTP
} // namespace RTC