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_PARAMETER_INCOMING_SSN_RESET_REQUEST_PARAMETER_H_ 11 #define NET_DCSCTP_PACKET_PARAMETER_INCOMING_SSN_RESET_REQUEST_PARAMETER_H_ 12 #include <stddef.h> 13 14 #include <cstdint> 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/common/internal_types.h" 22 #include "net/dcsctp/packet/parameter/parameter.h" 23 #include "net/dcsctp/public/types.h" 24 25 namespace dcsctp { 26 27 // https://tools.ietf.org/html/rfc6525#section-4.2 28 struct IncomingSSNResetRequestParameterConfig : ParameterConfig { 29 static constexpr int kType = 14; 30 static constexpr size_t kHeaderSize = 8; 31 static constexpr size_t kVariableLengthAlignment = 2; 32 }; 33 34 class IncomingSSNResetRequestParameter 35 : public Parameter, 36 public TLVTrait<IncomingSSNResetRequestParameterConfig> { 37 public: 38 static constexpr int kType = IncomingSSNResetRequestParameterConfig::kType; 39 IncomingSSNResetRequestParameter(ReconfigRequestSN request_sequence_number,std::vector<StreamID> stream_ids)40 explicit IncomingSSNResetRequestParameter( 41 ReconfigRequestSN request_sequence_number, 42 std::vector<StreamID> stream_ids) 43 : request_sequence_number_(request_sequence_number), 44 stream_ids_(std::move(stream_ids)) {} 45 46 static absl::optional<IncomingSSNResetRequestParameter> Parse( 47 rtc::ArrayView<const uint8_t> data); 48 49 void SerializeTo(std::vector<uint8_t>& out) const override; 50 std::string ToString() const override; 51 request_sequence_number()52 ReconfigRequestSN request_sequence_number() const { 53 return request_sequence_number_; 54 } stream_ids()55 rtc::ArrayView<const StreamID> stream_ids() const { return stream_ids_; } 56 57 private: 58 static constexpr size_t kStreamIdSize = sizeof(uint16_t); 59 60 ReconfigRequestSN request_sequence_number_; 61 std::vector<StreamID> stream_ids_; 62 }; 63 64 } // namespace dcsctp 65 66 #endif // NET_DCSCTP_PACKET_PARAMETER_INCOMING_SSN_RESET_REQUEST_PARAMETER_H_ 67