/* * Copyright 2011 The WebRTC Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef P2P_BASE_DTLS_TRANSPORT_H_ #define P2P_BASE_DTLS_TRANSPORT_H_ #include <memory> #include <string> #include <vector> #include "absl/strings/string_view.h" #include "api/crypto/crypto_options.h" #include "api/dtls_transport_interface.h" #include "api/sequence_checker.h" #include "p2p/base/dtls_transport_internal.h" #include "p2p/base/ice_transport_internal.h" #include "rtc_base/buffer.h" #include "rtc_base/buffer_queue.h" #include "rtc_base/network/received_packet.h" #include "rtc_base/ssl_stream_adapter.h" #include "rtc_base/stream.h" #include "rtc_base/strings/string_builder.h" #include "rtc_base/system/no_unique_address.h" namespace rtc { class PacketTransportInternal; } namespace cricket { // A bridge between a packet-oriented/transport-type interface on // the bottom and a StreamInterface on the top. class StreamInterfaceChannel : public rtc::StreamInterface { … }; // This class provides a DTLS SSLStreamAdapter inside a TransportChannel-style // packet-based interface, wrapping an existing TransportChannel instance // (e.g a P2PTransportChannel) // Here's the way this works: // // DtlsTransport { // SSLStreamAdapter* dtls_ { // StreamInterfaceChannel downward_ { // IceTransportInternal* ice_transport_; // } // } // } // // - Data which comes into DtlsTransport from the underlying // ice_transport_ via OnReadPacket() is checked for whether it is DTLS // or not, and if it is, is passed to DtlsTransport::HandleDtlsPacket, // which pushes it into to downward_. dtls_ is listening for events on // downward_, so it immediately calls downward_->Read(). // // - Data written to DtlsTransport is passed either to downward_ or directly // to ice_transport_, depending on whether DTLS is negotiated and whether // the flags include PF_SRTP_BYPASS // // - The SSLStreamAdapter writes to downward_->Write() which translates it // into packet writes on ice_transport_. // // This class is not thread safe; all methods must be called on the same thread // as the constructor. class DtlsTransport : public DtlsTransportInternal { … }; } // namespace cricket #endif // P2P_BASE_DTLS_TRANSPORT_H_