| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2011 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 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <utility> | 12 #include <utility> |
| 13 | 13 |
| 14 #include "webrtc/p2p/base/dtlstransportchannel.h" | 14 #include "webrtc/p2p/base/dtlstransportchannel.h" |
| 15 | 15 |
| 16 #include "webrtc/p2p/base/common.h" | 16 #include "webrtc/p2p/base/common.h" |
| 17 #include "webrtc/p2p/base/packettransportinterface.h" | 17 #include "webrtc/p2p/base/packettransportinternal.h" |
| 18 #include "webrtc/base/buffer.h" | 18 #include "webrtc/base/buffer.h" |
| 19 #include "webrtc/base/checks.h" | 19 #include "webrtc/base/checks.h" |
| 20 #include "webrtc/base/dscp.h" | 20 #include "webrtc/base/dscp.h" |
| 21 #include "webrtc/base/messagequeue.h" | 21 #include "webrtc/base/messagequeue.h" |
| 22 #include "webrtc/base/sslstreamadapter.h" | 22 #include "webrtc/base/sslstreamadapter.h" |
| 23 #include "webrtc/base/stream.h" | 23 #include "webrtc/base/stream.h" |
| 24 #include "webrtc/base/thread.h" | 24 #include "webrtc/base/thread.h" |
| 25 | 25 |
| 26 namespace cricket { | 26 namespace cricket { |
| 27 | 27 |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 // The state transition logic here is as follows: | 420 // The state transition logic here is as follows: |
| 421 // (1) If we're not doing DTLS-SRTP, then the state is just the | 421 // (1) If we're not doing DTLS-SRTP, then the state is just the |
| 422 // state of the underlying impl() | 422 // state of the underlying impl() |
| 423 // (2) If we're doing DTLS-SRTP: | 423 // (2) If we're doing DTLS-SRTP: |
| 424 // - Prior to the DTLS handshake, the state is neither receiving nor | 424 // - Prior to the DTLS handshake, the state is neither receiving nor |
| 425 // writable | 425 // writable |
| 426 // - When the impl goes writable for the first time we | 426 // - When the impl goes writable for the first time we |
| 427 // start the DTLS handshake | 427 // start the DTLS handshake |
| 428 // - Once the DTLS handshake completes, the state is that of the | 428 // - Once the DTLS handshake completes, the state is that of the |
| 429 // impl again | 429 // impl again |
| 430 void DtlsTransport::OnWritableState(rtc::PacketTransportInterface* transport) { | 430 void DtlsTransport::OnWritableState(rtc::PacketTransportInternal* transport) { |
| 431 RTC_DCHECK(rtc::Thread::Current() == network_thread_); | 431 RTC_DCHECK(rtc::Thread::Current() == network_thread_); |
| 432 RTC_DCHECK(transport == ice_transport_); | 432 RTC_DCHECK(transport == ice_transport_); |
| 433 LOG_J(LS_VERBOSE, this) | 433 LOG_J(LS_VERBOSE, this) |
| 434 << "DTLSTransportChannelWrapper: ice_transport writable state changed to " | 434 << "DTLSTransportChannelWrapper: ice_transport writable state changed to " |
| 435 << ice_transport_->writable(); | 435 << ice_transport_->writable(); |
| 436 | 436 |
| 437 if (!dtls_active_) { | 437 if (!dtls_active_) { |
| 438 // Not doing DTLS. | 438 // Not doing DTLS. |
| 439 // Note: SignalWritableState fired by set_writable. | 439 // Note: SignalWritableState fired by set_writable. |
| 440 set_writable(ice_transport_->writable()); | 440 set_writable(ice_transport_->writable()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 452 case DTLS_TRANSPORT_CONNECTING: | 452 case DTLS_TRANSPORT_CONNECTING: |
| 453 // Do nothing. | 453 // Do nothing. |
| 454 break; | 454 break; |
| 455 case DTLS_TRANSPORT_FAILED: | 455 case DTLS_TRANSPORT_FAILED: |
| 456 case DTLS_TRANSPORT_CLOSED: | 456 case DTLS_TRANSPORT_CLOSED: |
| 457 // Should not happen. Do nothing. | 457 // Should not happen. Do nothing. |
| 458 break; | 458 break; |
| 459 } | 459 } |
| 460 } | 460 } |
| 461 | 461 |
| 462 void DtlsTransport::OnReceivingState(rtc::PacketTransportInterface* transport) { | 462 void DtlsTransport::OnReceivingState(rtc::PacketTransportInternal* transport) { |
| 463 RTC_DCHECK(rtc::Thread::Current() == network_thread_); | 463 RTC_DCHECK(rtc::Thread::Current() == network_thread_); |
| 464 RTC_DCHECK(transport == ice_transport_); | 464 RTC_DCHECK(transport == ice_transport_); |
| 465 LOG_J(LS_VERBOSE, this) << "DTLSTransportChannelWrapper: ice_transport " | 465 LOG_J(LS_VERBOSE, this) << "DTLSTransportChannelWrapper: ice_transport " |
| 466 "receiving state changed to " | 466 "receiving state changed to " |
| 467 << ice_transport_->receiving(); | 467 << ice_transport_->receiving(); |
| 468 if (!dtls_active_ || dtls_state() == DTLS_TRANSPORT_CONNECTED) { | 468 if (!dtls_active_ || dtls_state() == DTLS_TRANSPORT_CONNECTED) { |
| 469 // Note: SignalReceivingState fired by set_receiving. | 469 // Note: SignalReceivingState fired by set_receiving. |
| 470 set_receiving(ice_transport_->receiving()); | 470 set_receiving(ice_transport_->receiving()); |
| 471 } | 471 } |
| 472 } | 472 } |
| 473 | 473 |
| 474 void DtlsTransport::OnReadPacket(rtc::PacketTransportInterface* transport, | 474 void DtlsTransport::OnReadPacket(rtc::PacketTransportInternal* transport, |
| 475 const char* data, | 475 const char* data, |
| 476 size_t size, | 476 size_t size, |
| 477 const rtc::PacketTime& packet_time, | 477 const rtc::PacketTime& packet_time, |
| 478 int flags) { | 478 int flags) { |
| 479 RTC_DCHECK(rtc::Thread::Current() == network_thread_); | 479 RTC_DCHECK(rtc::Thread::Current() == network_thread_); |
| 480 RTC_DCHECK(transport == ice_transport_); | 480 RTC_DCHECK(transport == ice_transport_); |
| 481 RTC_DCHECK(flags == 0); | 481 RTC_DCHECK(flags == 0); |
| 482 | 482 |
| 483 if (!dtls_active_) { | 483 if (!dtls_active_) { |
| 484 // Not doing DTLS. | 484 // Not doing DTLS. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 SignalReadPacket(this, data, size, packet_time, PF_SRTP_BYPASS); | 542 SignalReadPacket(this, data, size, packet_time, PF_SRTP_BYPASS); |
| 543 } | 543 } |
| 544 break; | 544 break; |
| 545 case DTLS_TRANSPORT_FAILED: | 545 case DTLS_TRANSPORT_FAILED: |
| 546 case DTLS_TRANSPORT_CLOSED: | 546 case DTLS_TRANSPORT_CLOSED: |
| 547 // This shouldn't be happening. Drop the packet. | 547 // This shouldn't be happening. Drop the packet. |
| 548 break; | 548 break; |
| 549 } | 549 } |
| 550 } | 550 } |
| 551 | 551 |
| 552 void DtlsTransport::OnSentPacket(rtc::PacketTransportInterface* transport, | 552 void DtlsTransport::OnSentPacket(rtc::PacketTransportInternal* transport, |
| 553 const rtc::SentPacket& sent_packet) { | 553 const rtc::SentPacket& sent_packet) { |
| 554 RTC_DCHECK(rtc::Thread::Current() == network_thread_); | 554 RTC_DCHECK(rtc::Thread::Current() == network_thread_); |
| 555 | 555 |
| 556 SignalSentPacket(this, sent_packet); | 556 SignalSentPacket(this, sent_packet); |
| 557 } | 557 } |
| 558 | 558 |
| 559 void DtlsTransport::OnReadyToSend(rtc::PacketTransportInterface* transport) { | 559 void DtlsTransport::OnReadyToSend(rtc::PacketTransportInternal* transport) { |
| 560 if (writable()) { | 560 if (writable()) { |
| 561 SignalReadyToSend(this); | 561 SignalReadyToSend(this); |
| 562 } | 562 } |
| 563 } | 563 } |
| 564 | 564 |
| 565 void DtlsTransport::OnDtlsEvent(rtc::StreamInterface* dtls, int sig, int err) { | 565 void DtlsTransport::OnDtlsEvent(rtc::StreamInterface* dtls, int sig, int err) { |
| 566 RTC_DCHECK(rtc::Thread::Current() == network_thread_); | 566 RTC_DCHECK(rtc::Thread::Current() == network_thread_); |
| 567 RTC_DCHECK(dtls == dtls_.get()); | 567 RTC_DCHECK(dtls == dtls_.get()); |
| 568 if (sig & rtc::SE_OPEN) { | 568 if (sig & rtc::SE_OPEN) { |
| 569 // This is the first time. | 569 // This is the first time. |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 | 715 |
| 716 dtls_->SetInitialRetransmissionTimeout(initial_timeout); | 716 dtls_->SetInitialRetransmissionTimeout(initial_timeout); |
| 717 } else { | 717 } else { |
| 718 LOG_J(LS_INFO, this) | 718 LOG_J(LS_INFO, this) |
| 719 << "no RTT estimate - using default DTLS handshake timeout"; | 719 << "no RTT estimate - using default DTLS handshake timeout"; |
| 720 } | 720 } |
| 721 } | 721 } |
| 722 | 722 |
| 723 | 723 |
| 724 } // namespace cricket | 724 } // namespace cricket |
| OLD | NEW |