/* * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef NET_DCSCTP_RX_REASSEMBLY_QUEUE_H_ #define NET_DCSCTP_RX_REASSEMBLY_QUEUE_H_ #include <stddef.h> #include <cstdint> #include <memory> #include <set> #include <string> #include <utility> #include <vector> #include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" #include "api/array_view.h" #include "net/dcsctp/common/internal_types.h" #include "net/dcsctp/common/sequence_numbers.h" #include "net/dcsctp/packet/chunk/forward_tsn_common.h" #include "net/dcsctp/packet/data.h" #include "net/dcsctp/packet/parameter/outgoing_ssn_reset_request_parameter.h" #include "net/dcsctp/packet/parameter/reconfiguration_response_parameter.h" #include "net/dcsctp/public/dcsctp_message.h" #include "net/dcsctp/rx/reassembly_streams.h" #include "rtc_base/containers/flat_set.h" namespace dcsctp { // Contains the received DATA chunks that haven't yet been reassembled, and // reassembles chunks when possible. // // The actual assembly is handled by an implementation of the // `ReassemblyStreams` interface. // // Except for reassembling fragmented messages, this class will also handle two // less common operations; To handle the receiver-side of partial reliability // (limited number of retransmissions or limited message lifetime) as well as // stream resetting, which is used when a sender wishes to close a data channel. // // Partial reliability is handled when a FORWARD-TSN or I-FORWARD-TSN chunk is // received, and it will simply delete any chunks matching the parameters in // that chunk. This is mainly implemented in ReassemblyStreams. // // Resetting streams is handled when a RECONFIG chunks is received, with an // "Outgoing SSN Reset Request" parameter. That parameter will contain a list of // streams to reset, and a `sender_last_assigned_tsn`. If this TSN is not yet // seen, the stream cannot be directly reset, and this class will respond that // the reset is "deferred". But if this TSN provided is known, the stream can be // immediately be reset. // // The ReassemblyQueue has a maximum size, as it would otherwise be an DoS // attack vector where a peer could consume all memory of the other peer by // sending a lot of ordered chunks, but carefully withholding an early one. It // also has a watermark limit, which the caller can query is the number of bytes // is above that limit. This is used by the caller to be selective in what to // add to the reassembly queue, so that it's not exhausted. The caller is // expected to call `is_full` prior to adding data to the queue and to act // accordingly if the queue is full. class ReassemblyQueue { … }; } // namespace dcsctp #endif // NET_DCSCTP_RX_REASSEMBLY_QUEUE_H_