Harald Alvestrand | 7061e51 | 2019-04-10 15:20:42 | [diff] [blame] | 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 | namespace webrtc { |
| 14 | |
| 15 | DtlsTransportInformation::DtlsTransportInformation() |
| 16 | : state_(DtlsTransportState::kNew) {} |
| 17 | |
| 18 | DtlsTransportInformation::DtlsTransportInformation(DtlsTransportState state) |
| 19 | : state_(state) {} |
| 20 | |
| 21 | DtlsTransportInformation::DtlsTransportInformation( |
| 22 | DtlsTransportState state, |
Harald Alvestrand | 316ab12 | 2022-02-10 08:23:47 | [diff] [blame] | 23 | absl::optional<DtlsTransportTlsRole> role, |
Harald Alvestrand | c6c3f86 | 2019-10-29 11:19:31 | [diff] [blame] | 24 | absl::optional<int> tls_version, |
Harald Alvestrand | 114871b | 2019-04-11 11:37:41 | [diff] [blame] | 25 | absl::optional<int> ssl_cipher_suite, |
Harald Alvestrand | c6c3f86 | 2019-10-29 11:19:31 | [diff] [blame] | 26 | absl::optional<int> srtp_cipher_suite, |
Harald Alvestrand | 7061e51 | 2019-04-10 15:20:42 | [diff] [blame] | 27 | std::unique_ptr<rtc::SSLCertChain> remote_ssl_certificates) |
| 28 | : state_(state), |
Harald Alvestrand | 316ab12 | 2022-02-10 08:23:47 | [diff] [blame] | 29 | role_(role), |
| 30 | tls_version_(tls_version), |
| 31 | ssl_cipher_suite_(ssl_cipher_suite), |
| 32 | srtp_cipher_suite_(srtp_cipher_suite), |
| 33 | remote_ssl_certificates_(std::move(remote_ssl_certificates)) {} |
| 34 | |
| 35 | // Deprecated version |
| 36 | DtlsTransportInformation::DtlsTransportInformation( |
| 37 | DtlsTransportState state, |
| 38 | absl::optional<int> tls_version, |
| 39 | absl::optional<int> ssl_cipher_suite, |
| 40 | absl::optional<int> srtp_cipher_suite, |
| 41 | std::unique_ptr<rtc::SSLCertChain> remote_ssl_certificates) |
| 42 | : state_(state), |
| 43 | role_(absl::nullopt), |
Harald Alvestrand | c6c3f86 | 2019-10-29 11:19:31 | [diff] [blame] | 44 | tls_version_(tls_version), |
Harald Alvestrand | 114871b | 2019-04-11 11:37:41 | [diff] [blame] | 45 | ssl_cipher_suite_(ssl_cipher_suite), |
Harald Alvestrand | c6c3f86 | 2019-10-29 11:19:31 | [diff] [blame] | 46 | srtp_cipher_suite_(srtp_cipher_suite), |
Harald Alvestrand | 7061e51 | 2019-04-10 15:20:42 | [diff] [blame] | 47 | remote_ssl_certificates_(std::move(remote_ssl_certificates)) {} |
| 48 | |
| 49 | DtlsTransportInformation::DtlsTransportInformation( |
| 50 | const DtlsTransportInformation& c) |
| 51 | : state_(c.state()), |
Harald Alvestrand | 316ab12 | 2022-02-10 08:23:47 | [diff] [blame] | 52 | role_(c.role_), |
Harald Alvestrand | c6c3f86 | 2019-10-29 11:19:31 | [diff] [blame] | 53 | tls_version_(c.tls_version_), |
Harald Alvestrand | 114871b | 2019-04-11 11:37:41 | [diff] [blame] | 54 | ssl_cipher_suite_(c.ssl_cipher_suite_), |
Harald Alvestrand | c6c3f86 | 2019-10-29 11:19:31 | [diff] [blame] | 55 | srtp_cipher_suite_(c.srtp_cipher_suite_), |
Harald Alvestrand | 7061e51 | 2019-04-10 15:20:42 | [diff] [blame] | 56 | remote_ssl_certificates_(c.remote_ssl_certificates() |
| 57 | ? c.remote_ssl_certificates()->Clone() |
| 58 | : nullptr) {} |
| 59 | |
| 60 | DtlsTransportInformation& DtlsTransportInformation::operator=( |
| 61 | const DtlsTransportInformation& c) { |
| 62 | state_ = c.state(); |
Harald Alvestrand | 316ab12 | 2022-02-10 08:23:47 | [diff] [blame] | 63 | role_ = c.role_; |
Harald Alvestrand | c6c3f86 | 2019-10-29 11:19:31 | [diff] [blame] | 64 | tls_version_ = c.tls_version_; |
Harald Alvestrand | 114871b | 2019-04-11 11:37:41 | [diff] [blame] | 65 | ssl_cipher_suite_ = c.ssl_cipher_suite_; |
Harald Alvestrand | c6c3f86 | 2019-10-29 11:19:31 | [diff] [blame] | 66 | srtp_cipher_suite_ = c.srtp_cipher_suite_; |
Harald Alvestrand | 7061e51 | 2019-04-10 15:20:42 | [diff] [blame] | 67 | remote_ssl_certificates_ = c.remote_ssl_certificates() |
| 68 | ? c.remote_ssl_certificates()->Clone() |
| 69 | : nullptr; |
| 70 | return *this; |
| 71 | } |
| 72 | |
| 73 | } // namespace webrtc |