#include "p2p/base/dtls_transport.h"
#include <algorithm>
#include <cstdint>
#include <memory>
#include <utility>
#include "absl/memory/memory.h"
#include "absl/strings/string_view.h"
#include "api/array_view.h"
#include "api/dtls_transport_interface.h"
#include "api/rtc_event_log/rtc_event_log.h"
#include "logging/rtc_event_log/events/rtc_event_dtls_transport_state.h"
#include "logging/rtc_event_log/events/rtc_event_dtls_writable_state.h"
#include "p2p/base/packet_transport_internal.h"
#include "rtc_base/buffer.h"
#include "rtc_base/checks.h"
#include "rtc_base/dscp.h"
#include "rtc_base/logging.h"
#include "rtc_base/network/received_packet.h"
#include "rtc_base/rtc_certificate.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/ssl_stream_adapter.h"
#include "rtc_base/stream.h"
#include "rtc_base/thread.h"
#include "rtc_base/time_utils.h"
namespace cricket {
static const size_t kDtlsRecordHeaderLen = …;
static const size_t kMaxDtlsPacketLen = …;
static const size_t kMinRtpPacketLen = …;
static const size_t kMaxPendingPackets = …;
static const int kMinHandshakeTimeout = …;
static const int kMaxHandshakeTimeout = …;
static bool IsDtlsPacket(rtc::ArrayView<const uint8_t> payload) { … }
static bool IsDtlsClientHelloPacket(rtc::ArrayView<const uint8_t> payload) { … }
static bool IsRtpPacket(rtc::ArrayView<const uint8_t> payload) { … }
StreamInterfaceChannel::StreamInterfaceChannel(
IceTransportInternal* ice_transport)
: … { … }
rtc::StreamResult StreamInterfaceChannel::Read(rtc::ArrayView<uint8_t> buffer,
size_t& read,
int& error) { … }
rtc::StreamResult StreamInterfaceChannel::Write(
rtc::ArrayView<const uint8_t> data,
size_t& written,
int& error) { … }
bool StreamInterfaceChannel::OnPacketReceived(const char* data, size_t size) { … }
rtc::StreamState StreamInterfaceChannel::GetState() const { … }
void StreamInterfaceChannel::Close() { … }
DtlsTransport::DtlsTransport(IceTransportInternal* ice_transport,
const webrtc::CryptoOptions& crypto_options,
webrtc::RtcEventLog* event_log,
rtc::SSLProtocolVersion max_version)
: … { … }
DtlsTransport::~DtlsTransport() { … }
webrtc::DtlsTransportState DtlsTransport::dtls_state() const { … }
const std::string& DtlsTransport::transport_name() const { … }
int DtlsTransport::component() const { … }
bool DtlsTransport::IsDtlsActive() const { … }
bool DtlsTransport::SetLocalCertificate(
const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) { … }
rtc::scoped_refptr<rtc::RTCCertificate> DtlsTransport::GetLocalCertificate()
const { … }
bool DtlsTransport::SetDtlsRole(rtc::SSLRole role) { … }
bool DtlsTransport::GetDtlsRole(rtc::SSLRole* role) const { … }
bool DtlsTransport::GetSslCipherSuite(int* cipher) { … }
webrtc::RTCError DtlsTransport::SetRemoteParameters(
absl::string_view digest_alg,
const uint8_t* digest,
size_t digest_len,
absl::optional<rtc::SSLRole> role) { … }
bool DtlsTransport::SetRemoteFingerprint(absl::string_view digest_alg,
const uint8_t* digest,
size_t digest_len) { … }
std::unique_ptr<rtc::SSLCertChain> DtlsTransport::GetRemoteSSLCertChain()
const { … }
bool DtlsTransport::ExportKeyingMaterial(absl::string_view label,
const uint8_t* context,
size_t context_len,
bool use_context,
uint8_t* result,
size_t result_len) { … }
bool DtlsTransport::SetupDtls() { … }
bool DtlsTransport::GetSrtpCryptoSuite(int* cipher) { … }
bool DtlsTransport::GetSslVersionBytes(int* version) const { … }
uint16_t DtlsTransport::GetSslPeerSignatureAlgorithm() const { … }
int DtlsTransport::SendPacket(const char* data,
size_t size,
const rtc::PacketOptions& options,
int flags) { … }
IceTransportInternal* DtlsTransport::ice_transport() { … }
bool DtlsTransport::IsDtlsConnected() { … }
bool DtlsTransport::receiving() const { … }
bool DtlsTransport::writable() const { … }
int DtlsTransport::GetError() { … }
absl::optional<rtc::NetworkRoute> DtlsTransport::network_route() const { … }
bool DtlsTransport::GetOption(rtc::Socket::Option opt, int* value) { … }
int DtlsTransport::SetOption(rtc::Socket::Option opt, int value) { … }
void DtlsTransport::ConnectToIceTransport() { … }
void DtlsTransport::OnWritableState(rtc::PacketTransportInternal* transport) { … }
void DtlsTransport::OnReceivingState(rtc::PacketTransportInternal* transport) { … }
void DtlsTransport::OnReadPacket(rtc::PacketTransportInternal* transport,
const rtc::ReceivedPacket& packet) { … }
void DtlsTransport::OnSentPacket(rtc::PacketTransportInternal* transport,
const rtc::SentPacket& sent_packet) { … }
void DtlsTransport::OnReadyToSend(rtc::PacketTransportInternal* transport) { … }
void DtlsTransport::OnDtlsEvent(int sig, int err) { … }
void DtlsTransport::OnNetworkRouteChanged(
absl::optional<rtc::NetworkRoute> network_route) { … }
void DtlsTransport::MaybeStartDtls() { … }
bool DtlsTransport::HandleDtlsPacket(rtc::ArrayView<const uint8_t> payload) { … }
void DtlsTransport::set_receiving(bool receiving) { … }
void DtlsTransport::set_writable(bool writable) { … }
void DtlsTransport::set_dtls_state(webrtc::DtlsTransportState state) { … }
void DtlsTransport::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { … }
void DtlsTransport::ConfigureHandshakeTimeout() { … }
}