dtls_transport_interface.cc (2904B)
1 /* 2 * Copyright 2019 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 11 #include "api/dtls_transport_interface.h" 12 13 #include <memory> 14 #include <optional> 15 #include <utility> 16 17 #include "rtc_base/ssl_certificate.h" 18 19 namespace webrtc { 20 21 DtlsTransportInformation::DtlsTransportInformation() 22 : state_(DtlsTransportState::kNew) {} 23 24 DtlsTransportInformation::DtlsTransportInformation(DtlsTransportState state) 25 : state_(state) {} 26 27 DtlsTransportInformation::DtlsTransportInformation( 28 DtlsTransportState state, 29 std::optional<DtlsTransportTlsRole> role, 30 std::optional<int> tls_version, 31 std::optional<int> ssl_cipher_suite, 32 std::optional<int> srtp_cipher_suite, 33 std::unique_ptr<SSLCertChain> remote_ssl_certificates, 34 std::optional<int> ssl_group_id) 35 : state_(state), 36 role_(role), 37 tls_version_(tls_version), 38 ssl_cipher_suite_(ssl_cipher_suite), 39 srtp_cipher_suite_(srtp_cipher_suite), 40 remote_ssl_certificates_(std::move(remote_ssl_certificates)), 41 ssl_group_id_(ssl_group_id) {} 42 43 // Deprecated version 44 DtlsTransportInformation::DtlsTransportInformation( 45 DtlsTransportState state, 46 std::optional<int> tls_version, 47 std::optional<int> ssl_cipher_suite, 48 std::optional<int> srtp_cipher_suite, 49 std::unique_ptr<SSLCertChain> remote_ssl_certificates) 50 : state_(state), 51 role_(std::nullopt), 52 tls_version_(tls_version), 53 ssl_cipher_suite_(ssl_cipher_suite), 54 srtp_cipher_suite_(srtp_cipher_suite), 55 remote_ssl_certificates_(std::move(remote_ssl_certificates)) {} 56 57 DtlsTransportInformation::DtlsTransportInformation( 58 const DtlsTransportInformation& c) 59 : state_(c.state()), 60 role_(c.role_), 61 tls_version_(c.tls_version_), 62 ssl_cipher_suite_(c.ssl_cipher_suite_), 63 srtp_cipher_suite_(c.srtp_cipher_suite_), 64 remote_ssl_certificates_(c.remote_ssl_certificates() 65 ? c.remote_ssl_certificates()->Clone() 66 : nullptr), 67 ssl_group_id_(c.ssl_group_id_) {} 68 69 DtlsTransportInformation& DtlsTransportInformation::operator=( 70 const DtlsTransportInformation& c) { 71 state_ = c.state(); 72 role_ = c.role_; 73 tls_version_ = c.tls_version_; 74 ssl_cipher_suite_ = c.ssl_cipher_suite_; 75 srtp_cipher_suite_ = c.srtp_cipher_suite_; 76 remote_ssl_certificates_ = c.remote_ssl_certificates() 77 ? c.remote_ssl_certificates()->Clone() 78 : nullptr; 79 ssl_group_id_ = c.ssl_group_id_; 80 return *this; 81 } 82 83 } // namespace webrtc