1 /* 2 * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 #ifndef NET_DCSCTP_PACKET_CHUNK_FORWARD_TSN_COMMON_H_ 11 #define NET_DCSCTP_PACKET_CHUNK_FORWARD_TSN_COMMON_H_ 12 #include <stdint.h> 13 14 #include <utility> 15 #include <vector> 16 17 #include "api/array_view.h" 18 #include "net/dcsctp/packet/chunk/chunk.h" 19 20 namespace dcsctp { 21 22 // Base class for both ForwardTsnChunk and IForwardTsnChunk 23 class AnyForwardTsnChunk : public Chunk { 24 public: 25 struct SkippedStream { SkippedStreamSkippedStream26 SkippedStream(StreamID stream_id, SSN ssn) 27 : stream_id(stream_id), ssn(ssn), unordered(false), message_id(0) {} SkippedStreamSkippedStream28 SkippedStream(IsUnordered unordered, StreamID stream_id, MID message_id) 29 : stream_id(stream_id), 30 ssn(0), 31 unordered(unordered), 32 message_id(message_id) {} 33 34 StreamID stream_id; 35 36 // Set for FORWARD_TSN 37 SSN ssn; 38 39 // Set for I-FORWARD_TSN 40 IsUnordered unordered; 41 MID message_id; 42 43 bool operator==(const SkippedStream& other) const { 44 return stream_id == other.stream_id && ssn == other.ssn && 45 unordered == other.unordered && message_id == other.message_id; 46 } 47 }; 48 AnyForwardTsnChunk(TSN new_cumulative_tsn,std::vector<SkippedStream> skipped_streams)49 AnyForwardTsnChunk(TSN new_cumulative_tsn, 50 std::vector<SkippedStream> skipped_streams) 51 : new_cumulative_tsn_(new_cumulative_tsn), 52 skipped_streams_(std::move(skipped_streams)) {} 53 new_cumulative_tsn()54 TSN new_cumulative_tsn() const { return new_cumulative_tsn_; } 55 skipped_streams()56 rtc::ArrayView<const SkippedStream> skipped_streams() const { 57 return skipped_streams_; 58 } 59 60 private: 61 TSN new_cumulative_tsn_; 62 std::vector<SkippedStream> skipped_streams_; 63 }; 64 } // namespace dcsctp 65 66 #endif // NET_DCSCTP_PACKET_CHUNK_FORWARD_TSN_COMMON_H_ 67