44#include " common.hpp"
55#include " RTC/SCTP/association/TCBContext.hpp"
66#include " RTC/SCTP/common/UnwrappedSequenceNumber.hpp"
7+ #include " RTC/SCTP/packet/Packet.hpp"
78#include " RTC/SCTP/packet/chunks/ReConfigChunk.hpp"
9+ #include " RTC/SCTP/packet/parameters/IncomingSsnResetRequestParameter.hpp"
10+ #include " RTC/SCTP/packet/parameters/OutgoingSsnResetRequestParameter.hpp"
811#include " RTC/SCTP/packet/parameters/ReconfigurationResponseParameter.hpp"
912#include " RTC/SCTP/public/AssociationListener.hpp"
1013#include " handles/BackoffTimerHandle.hpp"
@@ -53,7 +56,7 @@ namespace RTC
5356 {
5457 VALID,
5558 RETRANSMISSION,
56- BADSEQUENCE_NUMBER ,
59+ BAD_SEQUENCE_NUMBER ,
5760 };
5861
5962 /* *
@@ -156,6 +159,9 @@ namespace RTC
156159 bool isDeferred{ false };
157160 };
158161
162+ private:
163+ using UnwrappedReConfigRequestSn = UnwrappedSequenceNumber<uint32_t >;
164+
159165 public:
160166 StreamResetHandler (
161167 AssociationListener& associationListener, TCBContext* tcbContext
@@ -177,23 +183,66 @@ namespace RTC
177183 */
178184 void ResetStreams (std::span<const uint16_t > outgoingStreamIds);
179185
186+ /* *
187+ * Called when handling and incoming RE-CONFIG chunk. Processes a stream
188+ * reconfiguration chunk and may send a RE-CONFIG back to the peer with
189+ * either 1 or 2 responses.
190+ */
191+ void HandleReceivedReConfigChunk (const ReConfigChunk* receivedReConfigChunk);
192+
193+ private:
194+ /* *
195+ * Called to validate a received RE-CONFIG chunk.
196+ */
197+ bool ValidateReceivedReConfigChunk (const ReConfigChunk* receivedReConfigChunk);
198+
180199 /* *
181200 * Creates a Reset Streams request that must be sent if returned. Will
182201 * start the reconfig timer. Will return `nullptr` if there is no need
183202 * to create a request (no streams to reset) or if there already is an
184203 * ongoing stream reset request that hasn't completed yet.
185204 */
186- // TODO: SCTP: Do we really want to return a Chunk? Maybe we should pass
187- // a Packet to use BuilChunkInPlace().
188- ReConfigChunk* MakeStreamResetRequest ();
205+ ReConfigChunk* CreateStreamResetRequest ();
189206
190207 /* *
191- * Called when handling and incoming RE-CONFIG chunk.
208+ * Creates the actual RE-CONFIG chunk. A request (which set
209+ * `currentRequest`) must have been created prior.
192210 */
193- void ProcessReceivedReConfigChunk ( const ReConfigChunk* receivedReConfigChunk );
211+ ReConfigChunk* CreateReconfigChunk ( );
194212
195- private:
196- void OnReconfigTimer (uint64_t & baseTimeoutMs, bool & stop);
213+ /* *
214+ * Called to validate the `reqSeqNbr`, that it's the next in sequence.
215+ */
216+ ReqSeqNbrValidationResult ValidateReqSeqNbr (UnwrappedReConfigRequestSn reqSeqNbr);
217+
218+ /* *
219+ * Called when this Association receives an outgoing stream reset request.
220+ * It might either be performed straight away, or have to be deferred, and
221+ * the result of that will be put in `responses`.
222+ */
223+ void HandleReceivedOutgoingSsnResetRequestParameter (
224+ const OutgoingSsnResetRequestParameter* receivedOutgoingSsnResetRequestParameter,
225+ ReConfigChunk* reConfigChunk);
226+
227+ /* *
228+ * Called when this Association receives an incoming stream reset request.
229+ * This isn't really supported, but a successful response is put in
230+ * `responses`.
231+ */
232+ void HandleReceivedIncomingSsnResetRequestParameter (
233+ const IncomingSsnResetRequestParameter* receivedIncomingSsnResetRequestParameter,
234+ ReConfigChunk* reConfigChunk);
235+
236+ /* *
237+ * Called when receiving a response to an outgoing stream reset request.
238+ * It will either commit the stream resetting, if the operation was
239+ * successful, or will schedule a retry if it was deferred. And if it
240+ * failed, the operation will be rolled back.
241+ */
242+ void HandleReceivedReconfigurationResponseParameter (
243+ const ReconfigurationResponseParameter* receivedReconfigurationResponseParameter);
244+
245+ void OnReConfigTimer (uint64_t & baseTimeoutMs, bool & stop);
197246
198247 /* Pure virtual methods inherited from BackoffTimerHandle::Listener. */
199248 public:
@@ -206,14 +255,14 @@ namespace RTC
206255 // DataTracker* dataTracker{ nullptr };,
207256 // ReassemblyQueue* reassemblyQueue{ nullptr };,
208257 // RetransmissionQueue* retransmissionQueue{ nullptr };
209- UnwrappedSequenceNumber< uint32_t > ::Unwrapper incomingReconfigRequestSnUnwrapper ;
210- const std::unique_ptr<BackoffTimerHandle> reconfigTimer ;
258+ UnwrappedReConfigRequestSn ::Unwrapper incomingReConfigRequestSnUnwrapper ;
259+ const std::unique_ptr<BackoffTimerHandle> reConfigTimer ;
211260 // The next sequence number for outgoing stream requests.
212261 uint32_t nextOutgoingReqSeqNbr{ 0 };
213262 // The current stream request operation.
214263 std::optional<CurrentRequest> currentRequest;
215264 // For incoming requests. Last processed request sequence number.
216- UnwrappedSequenceNumber< uint32_t > lastProcessedReqSeqNbr;
265+ UnwrappedReConfigRequestSn lastProcessedReqSeqNbr;
217266 // The result from last processed incoming request.
218267 ReconfigurationResponseParameter::Result lastProcessedReqResult;
219268 };
0 commit comments