xref: /aosp_15_r20/external/webrtc/api/dtls_transport_interface.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1*d9f75844SAndroid Build Coastguard Worker /*
2*d9f75844SAndroid Build Coastguard Worker  *  Copyright 2019 The WebRTC project authors. All Rights Reserved.
3*d9f75844SAndroid Build Coastguard Worker  *
4*d9f75844SAndroid Build Coastguard Worker  *  Use of this source code is governed by a BSD-style license
5*d9f75844SAndroid Build Coastguard Worker  *  that can be found in the LICENSE file in the root of the source
6*d9f75844SAndroid Build Coastguard Worker  *  tree. An additional intellectual property rights grant can be found
7*d9f75844SAndroid Build Coastguard Worker  *  in the file PATENTS.  All contributing project authors may
8*d9f75844SAndroid Build Coastguard Worker  *  be found in the AUTHORS file in the root of the source tree.
9*d9f75844SAndroid Build Coastguard Worker  */
10*d9f75844SAndroid Build Coastguard Worker 
11*d9f75844SAndroid Build Coastguard Worker #include "api/dtls_transport_interface.h"
12*d9f75844SAndroid Build Coastguard Worker 
13*d9f75844SAndroid Build Coastguard Worker namespace webrtc {
14*d9f75844SAndroid Build Coastguard Worker 
DtlsTransportInformation()15*d9f75844SAndroid Build Coastguard Worker DtlsTransportInformation::DtlsTransportInformation()
16*d9f75844SAndroid Build Coastguard Worker     : state_(DtlsTransportState::kNew) {}
17*d9f75844SAndroid Build Coastguard Worker 
DtlsTransportInformation(DtlsTransportState state)18*d9f75844SAndroid Build Coastguard Worker DtlsTransportInformation::DtlsTransportInformation(DtlsTransportState state)
19*d9f75844SAndroid Build Coastguard Worker     : state_(state) {}
20*d9f75844SAndroid Build Coastguard Worker 
DtlsTransportInformation(DtlsTransportState state,absl::optional<DtlsTransportTlsRole> role,absl::optional<int> tls_version,absl::optional<int> ssl_cipher_suite,absl::optional<int> srtp_cipher_suite,std::unique_ptr<rtc::SSLCertChain> remote_ssl_certificates)21*d9f75844SAndroid Build Coastguard Worker DtlsTransportInformation::DtlsTransportInformation(
22*d9f75844SAndroid Build Coastguard Worker     DtlsTransportState state,
23*d9f75844SAndroid Build Coastguard Worker     absl::optional<DtlsTransportTlsRole> role,
24*d9f75844SAndroid Build Coastguard Worker     absl::optional<int> tls_version,
25*d9f75844SAndroid Build Coastguard Worker     absl::optional<int> ssl_cipher_suite,
26*d9f75844SAndroid Build Coastguard Worker     absl::optional<int> srtp_cipher_suite,
27*d9f75844SAndroid Build Coastguard Worker     std::unique_ptr<rtc::SSLCertChain> remote_ssl_certificates)
28*d9f75844SAndroid Build Coastguard Worker     : state_(state),
29*d9f75844SAndroid Build Coastguard Worker       role_(role),
30*d9f75844SAndroid Build Coastguard Worker       tls_version_(tls_version),
31*d9f75844SAndroid Build Coastguard Worker       ssl_cipher_suite_(ssl_cipher_suite),
32*d9f75844SAndroid Build Coastguard Worker       srtp_cipher_suite_(srtp_cipher_suite),
33*d9f75844SAndroid Build Coastguard Worker       remote_ssl_certificates_(std::move(remote_ssl_certificates)) {}
34*d9f75844SAndroid Build Coastguard Worker 
35*d9f75844SAndroid Build Coastguard Worker // Deprecated version
DtlsTransportInformation(DtlsTransportState state,absl::optional<int> tls_version,absl::optional<int> ssl_cipher_suite,absl::optional<int> srtp_cipher_suite,std::unique_ptr<rtc::SSLCertChain> remote_ssl_certificates)36*d9f75844SAndroid Build Coastguard Worker DtlsTransportInformation::DtlsTransportInformation(
37*d9f75844SAndroid Build Coastguard Worker     DtlsTransportState state,
38*d9f75844SAndroid Build Coastguard Worker     absl::optional<int> tls_version,
39*d9f75844SAndroid Build Coastguard Worker     absl::optional<int> ssl_cipher_suite,
40*d9f75844SAndroid Build Coastguard Worker     absl::optional<int> srtp_cipher_suite,
41*d9f75844SAndroid Build Coastguard Worker     std::unique_ptr<rtc::SSLCertChain> remote_ssl_certificates)
42*d9f75844SAndroid Build Coastguard Worker     : state_(state),
43*d9f75844SAndroid Build Coastguard Worker       role_(absl::nullopt),
44*d9f75844SAndroid Build Coastguard Worker       tls_version_(tls_version),
45*d9f75844SAndroid Build Coastguard Worker       ssl_cipher_suite_(ssl_cipher_suite),
46*d9f75844SAndroid Build Coastguard Worker       srtp_cipher_suite_(srtp_cipher_suite),
47*d9f75844SAndroid Build Coastguard Worker       remote_ssl_certificates_(std::move(remote_ssl_certificates)) {}
48*d9f75844SAndroid Build Coastguard Worker 
DtlsTransportInformation(const DtlsTransportInformation & c)49*d9f75844SAndroid Build Coastguard Worker DtlsTransportInformation::DtlsTransportInformation(
50*d9f75844SAndroid Build Coastguard Worker     const DtlsTransportInformation& c)
51*d9f75844SAndroid Build Coastguard Worker     : state_(c.state()),
52*d9f75844SAndroid Build Coastguard Worker       role_(c.role_),
53*d9f75844SAndroid Build Coastguard Worker       tls_version_(c.tls_version_),
54*d9f75844SAndroid Build Coastguard Worker       ssl_cipher_suite_(c.ssl_cipher_suite_),
55*d9f75844SAndroid Build Coastguard Worker       srtp_cipher_suite_(c.srtp_cipher_suite_),
56*d9f75844SAndroid Build Coastguard Worker       remote_ssl_certificates_(c.remote_ssl_certificates()
57*d9f75844SAndroid Build Coastguard Worker                                    ? c.remote_ssl_certificates()->Clone()
58*d9f75844SAndroid Build Coastguard Worker                                    : nullptr) {}
59*d9f75844SAndroid Build Coastguard Worker 
operator =(const DtlsTransportInformation & c)60*d9f75844SAndroid Build Coastguard Worker DtlsTransportInformation& DtlsTransportInformation::operator=(
61*d9f75844SAndroid Build Coastguard Worker     const DtlsTransportInformation& c) {
62*d9f75844SAndroid Build Coastguard Worker   state_ = c.state();
63*d9f75844SAndroid Build Coastguard Worker   role_ = c.role_;
64*d9f75844SAndroid Build Coastguard Worker   tls_version_ = c.tls_version_;
65*d9f75844SAndroid Build Coastguard Worker   ssl_cipher_suite_ = c.ssl_cipher_suite_;
66*d9f75844SAndroid Build Coastguard Worker   srtp_cipher_suite_ = c.srtp_cipher_suite_;
67*d9f75844SAndroid Build Coastguard Worker   remote_ssl_certificates_ = c.remote_ssl_certificates()
68*d9f75844SAndroid Build Coastguard Worker                                  ? c.remote_ssl_certificates()->Clone()
69*d9f75844SAndroid Build Coastguard Worker                                  : nullptr;
70*d9f75844SAndroid Build Coastguard Worker   return *this;
71*d9f75844SAndroid Build Coastguard Worker }
72*d9f75844SAndroid Build Coastguard Worker 
73*d9f75844SAndroid Build Coastguard Worker }  // namespace webrtc
74