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 #include "net/dcsctp/packet/error_cause/invalid_mandatory_parameter_cause.h" 11 12 #include <stdint.h> 13 14 #include <vector> 15 16 #include "absl/types/optional.h" 17 #include "api/array_view.h" 18 19 namespace dcsctp { 20 21 // https://tools.ietf.org/html/rfc4960#section-3.3.10.7 22 23 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 24 // | Cause Code=7 | Cause Length=4 | 25 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 26 constexpr int InvalidMandatoryParameterCause::kType; 27 28 absl::optional<InvalidMandatoryParameterCause> Parse(rtc::ArrayView<const uint8_t> data)29InvalidMandatoryParameterCause::Parse(rtc::ArrayView<const uint8_t> data) { 30 if (!ParseTLV(data).has_value()) { 31 return absl::nullopt; 32 } 33 return InvalidMandatoryParameterCause(); 34 } 35 SerializeTo(std::vector<uint8_t> & out) const36void InvalidMandatoryParameterCause::SerializeTo( 37 std::vector<uint8_t>& out) const { 38 AllocateTLV(out); 39 } 40 ToString() const41std::string InvalidMandatoryParameterCause::ToString() const { 42 return "Invalid Mandatory Parameter"; 43 } 44 45 } // namespace dcsctp 46