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_CHUNK_H_ 11 #define NET_DCSCTP_PACKET_CHUNK_FORWARD_TSN_CHUNK_H_ 12 #include <stddef.h> 13 #include <stdint.h> 14 15 #include <string> 16 #include <utility> 17 #include <vector> 18 19 #include "absl/strings/string_view.h" 20 #include "api/array_view.h" 21 #include "net/dcsctp/packet/chunk/chunk.h" 22 #include "net/dcsctp/packet/chunk/forward_tsn_common.h" 23 #include "net/dcsctp/packet/tlv_trait.h" 24 25 namespace dcsctp { 26 27 // https://tools.ietf.org/html/rfc3758#section-3.2 28 struct ForwardTsnChunkConfig : ChunkConfig { 29 static constexpr int kType = 192; 30 static constexpr size_t kHeaderSize = 8; 31 static constexpr size_t kVariableLengthAlignment = 4; 32 }; 33 34 class ForwardTsnChunk : public AnyForwardTsnChunk, 35 public TLVTrait<ForwardTsnChunkConfig> { 36 public: 37 static constexpr int kType = ForwardTsnChunkConfig::kType; 38 ForwardTsnChunk(TSN new_cumulative_tsn,std::vector<SkippedStream> skipped_streams)39 ForwardTsnChunk(TSN new_cumulative_tsn, 40 std::vector<SkippedStream> skipped_streams) 41 : AnyForwardTsnChunk(new_cumulative_tsn, std::move(skipped_streams)) {} 42 43 static absl::optional<ForwardTsnChunk> Parse( 44 rtc::ArrayView<const uint8_t> data); 45 46 void SerializeTo(std::vector<uint8_t>& out) const override; 47 std::string ToString() const override; 48 49 private: 50 static constexpr size_t kSkippedStreamBufferSize = 4; 51 }; 52 53 } // namespace dcsctp 54 55 #endif // NET_DCSCTP_PACKET_CHUNK_FORWARD_TSN_CHUNK_H_ 56