diff options
Diffstat (limited to 'third_party/libwebrtc/net/dcsctp/packet/parameter/zero_checksum_acceptable_chunk_parameter.cc')
-rw-r--r-- | third_party/libwebrtc/net/dcsctp/packet/parameter/zero_checksum_acceptable_chunk_parameter.cc | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/third_party/libwebrtc/net/dcsctp/packet/parameter/zero_checksum_acceptable_chunk_parameter.cc b/third_party/libwebrtc/net/dcsctp/packet/parameter/zero_checksum_acceptable_chunk_parameter.cc index 75f7d3c487..a846d6dff3 100644 --- a/third_party/libwebrtc/net/dcsctp/packet/parameter/zero_checksum_acceptable_chunk_parameter.cc +++ b/third_party/libwebrtc/net/dcsctp/packet/parameter/zero_checksum_acceptable_chunk_parameter.cc @@ -15,32 +15,44 @@ #include "absl/types/optional.h" #include "api/array_view.h" +#include "rtc_base/strings/string_builder.h" namespace dcsctp { // https://www.ietf.org/archive/id/draft-tuexen-tsvwg-sctp-zero-checksum-00.html#section-3 -// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// | Type = 0x8001 | Length = 4 | -// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Type = 0x8001 (suggested) | Length = 8 | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +// | Error Detection Method Identifier (EDMID) | +// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ constexpr int ZeroChecksumAcceptableChunkParameter::kType; absl::optional<ZeroChecksumAcceptableChunkParameter> ZeroChecksumAcceptableChunkParameter::Parse( rtc::ArrayView<const uint8_t> data) { - if (!ParseTLV(data).has_value()) { + absl::optional<BoundedByteReader<kHeaderSize>> reader = ParseTLV(data); + if (!reader.has_value()) { return absl::nullopt; } - return ZeroChecksumAcceptableChunkParameter(); + + ZeroChecksumAlternateErrorDetectionMethod method(reader->Load32<4>()); + if (method == ZeroChecksumAlternateErrorDetectionMethod::None()) { + return absl::nullopt; + } + return ZeroChecksumAcceptableChunkParameter(method); } void ZeroChecksumAcceptableChunkParameter::SerializeTo( std::vector<uint8_t>& out) const { - AllocateTLV(out); + BoundedByteWriter<kHeaderSize> writer = AllocateTLV(out); + writer.Store32<4>(*error_detection_method_); } std::string ZeroChecksumAcceptableChunkParameter::ToString() const { - return "Zero Checksum Acceptable"; + rtc::StringBuilder sb; + sb << "Zero Checksum Acceptable (" << *error_detection_method_ << ")"; + return sb.Release(); } } // namespace dcsctp |