| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 // Once the wrapped transport channel is connected, QuicTransportChannel | 41 // Once the wrapped transport channel is connected, QuicTransportChannel |
| 42 // negotiates the crypto handshake and establishes SRTP keying material. | 42 // negotiates the crypto handshake and establishes SRTP keying material. |
| 43 // | 43 // |
| 44 // How it works: | 44 // How it works: |
| 45 // | 45 // |
| 46 // QuicTransportChannel { | 46 // QuicTransportChannel { |
| 47 // QuicSession* quic_; | 47 // QuicSession* quic_; |
| 48 // TransportChannelImpl* channel_; | 48 // TransportChannelImpl* channel_; |
| 49 // } | 49 // } |
| 50 // | 50 // |
| 51 // - Data written to SendPacket() is passed directly to |channel_| if it is | 51 // - Data written to SendPacket() is passed directly to |channel_| if it is |
| 52 // an SRTP packet with the PF_SRTP_BYPASS flag. | 52 // an SRTP packet with the PF_SRTP_BYPASS flag. |
| 53 // | 53 // |
| 54 // - |quic_| passes outgoing packets to WritePacket(), which transfers them | 54 // - |quic_| passes outgoing packets to WritePacket(), which transfers them |
| 55 // to |channel_| to be sent across the network. | 55 // to |channel_| to be sent across the network. |
| 56 // | 56 // |
| 57 // - Data which comes into QuicTransportChannel::OnReadPacket is checked to | 57 // - Data which comes into QuicTransportChannel::OnReadPacket is checked to |
| 58 // see if it is QUIC, and if it is, passed to |quic_|. SRTP packets are | 58 // see if it is QUIC, and if it is, passed to |quic_|. SRTP packets are |
| 59 // signaled upwards as bypass packets. | 59 // signaled upwards as bypass packets. |
| 60 // | 60 // |
| 61 // - When the QUIC handshake is completed, quic_state() returns | 61 // - When the QUIC handshake is completed, quic_state() returns |
| 62 // QUIC_TRANSPORT_CONNECTED and SRTP keying material can be exported. | 62 // QUIC_TRANSPORT_CONNECTED and SRTP keying material can be exported. |
| 63 // | 63 // |
| 64 // TODO(mikescarlett): Implement secure QUIC handshake, 0-RTT handshakes, and | 64 // - CreateQuicStream() creates an outgoing QUIC stream. Once the local peer |
| 65 // QUIC data streams. | 65 // sends data from this stream, the remote peer emits SignalIncomingStream |
| 66 // with a QUIC stream of the same id to handle received data. |
| 67 // |
| 68 // TODO(mikescarlett): Implement secure QUIC handshake and 0-RTT handshakes. |
| 66 class QuicTransportChannel : public TransportChannelImpl, | 69 class QuicTransportChannel : public TransportChannelImpl, |
| 67 public net::QuicPacketWriter, | 70 public net::QuicPacketWriter, |
| 68 public net::QuicCryptoClientStream::ProofHandler { | 71 public net::QuicCryptoClientStream::ProofHandler { |
| 69 public: | 72 public: |
| 70 // |channel| - the TransportChannelImpl we are wrapping. | 73 // |channel| - the TransportChannelImpl we are wrapping. |
| 71 explicit QuicTransportChannel(TransportChannelImpl* channel); | 74 explicit QuicTransportChannel(TransportChannelImpl* channel); |
| 72 ~QuicTransportChannel() override; | 75 ~QuicTransportChannel() override; |
| 73 | 76 |
| 74 // TransportChannel overrides. | 77 // TransportChannel overrides. |
| 75 // TODO(mikescarlett): Implement certificate authentication. | 78 // TODO(mikescarlett): Implement certificate authentication. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 106 // this extracts the keys negotiated during the QUIC handshake, for use | 109 // this extracts the keys negotiated during the QUIC handshake, for use |
| 107 // in external encryption such as for extracting SRTP keys. | 110 // in external encryption such as for extracting SRTP keys. |
| 108 bool ExportKeyingMaterial(const std::string& label, | 111 bool ExportKeyingMaterial(const std::string& label, |
| 109 const uint8_t* context, | 112 const uint8_t* context, |
| 110 size_t context_len, | 113 size_t context_len, |
| 111 bool use_context, | 114 bool use_context, |
| 112 uint8_t* result, | 115 uint8_t* result, |
| 113 size_t result_len) override; | 116 size_t result_len) override; |
| 114 // TODO(mikescarlett): Remove this method once TransportChannel does not | 117 // TODO(mikescarlett): Remove this method once TransportChannel does not |
| 115 // require defining it. | 118 // require defining it. |
| 116 bool GetRemoteSSLCertificate(rtc::SSLCertificate** cert) const override { | 119 rtc::scoped_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate() |
| 117 return false; | 120 const override { |
| 121 return nullptr; |
| 118 } | 122 } |
| 119 | 123 |
| 120 // TransportChannelImpl overrides that we forward to the wrapped transport. | 124 // TransportChannelImpl overrides that we forward to the wrapped transport. |
| 121 void SetIceRole(IceRole role) override { channel_->SetIceRole(role); } | 125 void SetIceRole(IceRole role) override { channel_->SetIceRole(role); } |
| 122 IceRole GetIceRole() const override { return channel_->GetIceRole(); } | 126 IceRole GetIceRole() const override { return channel_->GetIceRole(); } |
| 123 int SetOption(rtc::Socket::Option opt, int value) override { | 127 int SetOption(rtc::Socket::Option opt, int value) override { |
| 124 return channel_->SetOption(opt, value); | 128 return channel_->SetOption(opt, value); |
| 125 } | 129 } |
| 126 bool GetOption(rtc::Socket::Option opt, int* value) override { | 130 bool GetOption(rtc::Socket::Option opt, int* value) override { |
| 127 return channel_->GetOption(opt, value); | 131 return channel_->GetOption(opt, value); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 void OnProofVerifyDetailsAvailable( | 203 void OnProofVerifyDetailsAvailable( |
| 200 const net::ProofVerifyDetails& verify_details) override; | 204 const net::ProofVerifyDetails& verify_details) override; |
| 201 | 205 |
| 202 // Returns true if |quic_| has queued data which wasn't written due | 206 // Returns true if |quic_| has queued data which wasn't written due |
| 203 // to |channel_| being write blocked. | 207 // to |channel_| being write blocked. |
| 204 bool HasDataToWrite() const; | 208 bool HasDataToWrite() const; |
| 205 // Writes queued data for |quic_| when |channel_| is no longer write blocked. | 209 // Writes queued data for |quic_| when |channel_| is no longer write blocked. |
| 206 void OnCanWrite(); | 210 void OnCanWrite(); |
| 207 // Connectivity state of QuicTransportChannel. | 211 // Connectivity state of QuicTransportChannel. |
| 208 QuicTransportState quic_state() const { return quic_state_; } | 212 QuicTransportState quic_state() const { return quic_state_; } |
| 213 // Creates a new QUIC stream that can send data. |
| 214 ReliableQuicStream* CreateQuicStream(); |
| 215 |
| 216 // Emitted when |quic_| creates a QUIC stream to receive data from the remote |
| 217 // peer, when the stream did not exist previously. |
| 218 sigslot::signal1<ReliableQuicStream*> SignalIncomingStream; |
| 219 // Emitted when the QuicTransportChannel state becomes QUIC_TRANSPORT_CLOSED. |
| 220 sigslot::signal0<> SignalClosed; |
| 209 | 221 |
| 210 private: | 222 private: |
| 211 // Fingerprint of remote peer. | 223 // Fingerprint of remote peer. |
| 212 struct RemoteFingerprint { | 224 struct RemoteFingerprint { |
| 213 std::string value; | 225 std::string value; |
| 214 std::string algorithm; | 226 std::string algorithm; |
| 215 }; | 227 }; |
| 216 | 228 |
| 217 // Callbacks for |channel_|. | 229 // Callbacks for |channel_|. |
| 218 void OnReadableState(TransportChannel* channel); | 230 void OnReadableState(TransportChannel* channel); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 234 TransportChannel* channel, | 246 TransportChannel* channel, |
| 235 CandidatePairInterface* selected_candidate_pair, | 247 CandidatePairInterface* selected_candidate_pair, |
| 236 int last_sent_packet_id); | 248 int last_sent_packet_id); |
| 237 void OnConnectionRemoved(TransportChannelImpl* channel); | 249 void OnConnectionRemoved(TransportChannelImpl* channel); |
| 238 | 250 |
| 239 // Callbacks for |quic_|. | 251 // Callbacks for |quic_|. |
| 240 // Called when |quic_| has established the crypto handshake. | 252 // Called when |quic_| has established the crypto handshake. |
| 241 void OnHandshakeComplete(); | 253 void OnHandshakeComplete(); |
| 242 // Called when |quic_| has closed the connection. | 254 // Called when |quic_| has closed the connection. |
| 243 void OnConnectionClosed(net::QuicErrorCode error, bool from_peer); | 255 void OnConnectionClosed(net::QuicErrorCode error, bool from_peer); |
| 256 // Called when |quic_| has created a new QUIC stream for incoming data. |
| 257 void OnIncomingStream(ReliableQuicStream* stream); |
| 244 | 258 |
| 245 // Called by OnReadPacket() when a QUIC packet is received. | 259 // Called by OnReadPacket() when a QUIC packet is received. |
| 246 bool HandleQuicPacket(const char* data, size_t size); | 260 bool HandleQuicPacket(const char* data, size_t size); |
| 247 // Sets up the QUIC handshake. | 261 // Sets up the QUIC handshake. |
| 248 bool MaybeStartQuic(); | 262 bool MaybeStartQuic(); |
| 249 // Creates the QUIC connection and |quic_|. | 263 // Creates the QUIC connection and |quic_|. |
| 250 bool CreateQuicSession(); | 264 bool CreateQuicSession(); |
| 251 // Creates the crypto stream and initializes the handshake. | 265 // Creates the crypto stream and initializes the handshake. |
| 252 bool StartQuicHandshake(); | 266 bool StartQuicHandshake(); |
| 253 // Sets the QuicTransportChannel connectivity state. | 267 // Sets the QuicTransportChannel connectivity state. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 280 rtc::scoped_refptr<rtc::RTCCertificate> local_certificate_; | 294 rtc::scoped_refptr<rtc::RTCCertificate> local_certificate_; |
| 281 // Fingerprint of the remote peer. This must be set before we start QUIC. | 295 // Fingerprint of the remote peer. This must be set before we start QUIC. |
| 282 rtc::Optional<RemoteFingerprint> remote_fingerprint_; | 296 rtc::Optional<RemoteFingerprint> remote_fingerprint_; |
| 283 | 297 |
| 284 RTC_DISALLOW_COPY_AND_ASSIGN(QuicTransportChannel); | 298 RTC_DISALLOW_COPY_AND_ASSIGN(QuicTransportChannel); |
| 285 }; | 299 }; |
| 286 | 300 |
| 287 } // namespace cricket | 301 } // namespace cricket |
| 288 | 302 |
| 289 #endif // WEBRTC_P2P_QUIC_QUICTRANSPORTCHANNEL_H_ | 303 #endif // WEBRTC_P2P_QUIC_QUICTRANSPORTCHANNEL_H_ |
| OLD | NEW |