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/out_of_resource_error_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.4 22 23 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 24 // | Cause Code=4 | Cause Length=4 | 25 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 26 constexpr int OutOfResourceErrorCause::kType; 27 Parse(rtc::ArrayView<const uint8_t> data)28absl::optional<OutOfResourceErrorCause> OutOfResourceErrorCause::Parse( 29 rtc::ArrayView<const uint8_t> data) { 30 if (!ParseTLV(data).has_value()) { 31 return absl::nullopt; 32 } 33 return OutOfResourceErrorCause(); 34 } 35 SerializeTo(std::vector<uint8_t> & out) const36void OutOfResourceErrorCause::SerializeTo(std::vector<uint8_t>& out) const { 37 AllocateTLV(out); 38 } 39 ToString() const40std::string OutOfResourceErrorCause::ToString() const { 41 return "Out Of Resource"; 42 } 43 44 } // namespace dcsctp 45