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_VALIDATORS_H_ 11 #define NET_DCSCTP_PACKET_CHUNK_VALIDATORS_H_ 12 13 #include "net/dcsctp/packet/chunk/sack_chunk.h" 14 15 namespace dcsctp { 16 // Validates and cleans SCTP chunks. 17 class ChunkValidators { 18 public: 19 // Given a SackChunk, will return `true` if it's valid, and `false` if not. 20 static bool Validate(const SackChunk& sack); 21 22 // Given a SackChunk, it will return a cleaned and validated variant of it. 23 // RFC4960 doesn't say anything about validity of SACKs or if the Gap ACK 24 // blocks must be sorted, and non-overlapping. While they always are in 25 // well-behaving implementations, this can't be relied on. 26 // 27 // This method internally calls `Validate`, which means that you can always 28 // pass a SackChunk to this method (valid or not), and use the results. 29 static SackChunk Clean(SackChunk&& sack); 30 }; 31 } // namespace dcsctp 32 33 #endif // NET_DCSCTP_PACKET_CHUNK_VALIDATORS_H_ 34