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 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 97 } |
98 | 98 |
99 void StreamInterfaceChannel::Close() { | 99 void StreamInterfaceChannel::Close() { |
100 packets_.Clear(); | 100 packets_.Clear(); |
101 state_ = rtc::SS_CLOSED; | 101 state_ = rtc::SS_CLOSED; |
102 } | 102 } |
103 | 103 |
104 DtlsTransportChannelWrapper::DtlsTransportChannelWrapper( | 104 DtlsTransportChannelWrapper::DtlsTransportChannelWrapper( |
105 TransportChannelImpl* channel) | 105 TransportChannelImpl* channel) |
106 : TransportChannelImpl(channel->transport_name(), channel->component()), | 106 : TransportChannelImpl(channel->transport_name(), channel->component()), |
107 worker_thread_(rtc::Thread::Current()), | 107 network_thread_(rtc::Thread::Current()), |
108 channel_(channel), | 108 channel_(channel), |
109 downward_(NULL), | 109 downward_(NULL), |
110 ssl_role_(rtc::SSL_CLIENT), | 110 ssl_role_(rtc::SSL_CLIENT), |
111 ssl_max_version_(rtc::SSL_PROTOCOL_DTLS_12) { | 111 ssl_max_version_(rtc::SSL_PROTOCOL_DTLS_12) { |
112 channel_->SignalWritableState.connect(this, | 112 channel_->SignalWritableState.connect(this, |
113 &DtlsTransportChannelWrapper::OnWritableState); | 113 &DtlsTransportChannelWrapper::OnWritableState); |
114 channel_->SignalReadPacket.connect(this, | 114 channel_->SignalReadPacket.connect(this, |
115 &DtlsTransportChannelWrapper::OnReadPacket); | 115 &DtlsTransportChannelWrapper::OnReadPacket); |
116 channel_->SignalSentPacket.connect( | 116 channel_->SignalSentPacket.connect( |
117 this, &DtlsTransportChannelWrapper::OnSentPacket); | 117 this, &DtlsTransportChannelWrapper::OnSentPacket); |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 // (1) If we're not doing DTLS-SRTP, then the state is just the | 431 // (1) If we're not doing DTLS-SRTP, then the state is just the |
432 // state of the underlying impl() | 432 // state of the underlying impl() |
433 // (2) If we're doing DTLS-SRTP: | 433 // (2) If we're doing DTLS-SRTP: |
434 // - Prior to the DTLS handshake, the state is neither receiving nor | 434 // - Prior to the DTLS handshake, the state is neither receiving nor |
435 // writable | 435 // writable |
436 // - When the impl goes writable for the first time we | 436 // - When the impl goes writable for the first time we |
437 // start the DTLS handshake | 437 // start the DTLS handshake |
438 // - Once the DTLS handshake completes, the state is that of the | 438 // - Once the DTLS handshake completes, the state is that of the |
439 // impl again | 439 // impl again |
440 void DtlsTransportChannelWrapper::OnWritableState(TransportChannel* channel) { | 440 void DtlsTransportChannelWrapper::OnWritableState(TransportChannel* channel) { |
441 ASSERT(rtc::Thread::Current() == worker_thread_); | 441 ASSERT(rtc::Thread::Current() == network_thread_); |
442 ASSERT(channel == channel_); | 442 ASSERT(channel == channel_); |
443 LOG_J(LS_VERBOSE, this) | 443 LOG_J(LS_VERBOSE, this) |
444 << "DTLSTransportChannelWrapper: channel writable state changed to " | 444 << "DTLSTransportChannelWrapper: channel writable state changed to " |
445 << channel_->writable(); | 445 << channel_->writable(); |
446 | 446 |
447 if (!dtls_active_) { | 447 if (!dtls_active_) { |
448 // Not doing DTLS. | 448 // Not doing DTLS. |
449 // Note: SignalWritableState fired by set_writable. | 449 // Note: SignalWritableState fired by set_writable. |
450 set_writable(channel_->writable()); | 450 set_writable(channel_->writable()); |
451 return; | 451 return; |
(...skipping 11 matching lines...) Expand all Loading... |
463 // Do nothing. | 463 // Do nothing. |
464 break; | 464 break; |
465 case DTLS_TRANSPORT_FAILED: | 465 case DTLS_TRANSPORT_FAILED: |
466 case DTLS_TRANSPORT_CLOSED: | 466 case DTLS_TRANSPORT_CLOSED: |
467 // Should not happen. Do nothing. | 467 // Should not happen. Do nothing. |
468 break; | 468 break; |
469 } | 469 } |
470 } | 470 } |
471 | 471 |
472 void DtlsTransportChannelWrapper::OnReceivingState(TransportChannel* channel) { | 472 void DtlsTransportChannelWrapper::OnReceivingState(TransportChannel* channel) { |
473 ASSERT(rtc::Thread::Current() == worker_thread_); | 473 ASSERT(rtc::Thread::Current() == network_thread_); |
474 ASSERT(channel == channel_); | 474 ASSERT(channel == channel_); |
475 LOG_J(LS_VERBOSE, this) | 475 LOG_J(LS_VERBOSE, this) |
476 << "DTLSTransportChannelWrapper: channel receiving state changed to " | 476 << "DTLSTransportChannelWrapper: channel receiving state changed to " |
477 << channel_->receiving(); | 477 << channel_->receiving(); |
478 if (!dtls_active_ || dtls_state() == DTLS_TRANSPORT_CONNECTED) { | 478 if (!dtls_active_ || dtls_state() == DTLS_TRANSPORT_CONNECTED) { |
479 // Note: SignalReceivingState fired by set_receiving. | 479 // Note: SignalReceivingState fired by set_receiving. |
480 set_receiving(channel_->receiving()); | 480 set_receiving(channel_->receiving()); |
481 } | 481 } |
482 } | 482 } |
483 | 483 |
484 void DtlsTransportChannelWrapper::OnReadPacket( | 484 void DtlsTransportChannelWrapper::OnReadPacket( |
485 TransportChannel* channel, const char* data, size_t size, | 485 TransportChannel* channel, const char* data, size_t size, |
486 const rtc::PacketTime& packet_time, int flags) { | 486 const rtc::PacketTime& packet_time, int flags) { |
487 ASSERT(rtc::Thread::Current() == worker_thread_); | 487 ASSERT(rtc::Thread::Current() == network_thread_); |
488 ASSERT(channel == channel_); | 488 ASSERT(channel == channel_); |
489 ASSERT(flags == 0); | 489 ASSERT(flags == 0); |
490 | 490 |
491 if (!dtls_active_) { | 491 if (!dtls_active_) { |
492 // Not doing DTLS. | 492 // Not doing DTLS. |
493 SignalReadPacket(this, data, size, packet_time, 0); | 493 SignalReadPacket(this, data, size, packet_time, 0); |
494 return; | 494 return; |
495 } | 495 } |
496 | 496 |
497 switch (dtls_state()) { | 497 switch (dtls_state()) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 case DTLS_TRANSPORT_FAILED: | 553 case DTLS_TRANSPORT_FAILED: |
554 case DTLS_TRANSPORT_CLOSED: | 554 case DTLS_TRANSPORT_CLOSED: |
555 // This shouldn't be happening. Drop the packet. | 555 // This shouldn't be happening. Drop the packet. |
556 break; | 556 break; |
557 } | 557 } |
558 } | 558 } |
559 | 559 |
560 void DtlsTransportChannelWrapper::OnSentPacket( | 560 void DtlsTransportChannelWrapper::OnSentPacket( |
561 TransportChannel* channel, | 561 TransportChannel* channel, |
562 const rtc::SentPacket& sent_packet) { | 562 const rtc::SentPacket& sent_packet) { |
563 ASSERT(rtc::Thread::Current() == worker_thread_); | 563 ASSERT(rtc::Thread::Current() == network_thread_); |
564 | 564 |
565 SignalSentPacket(this, sent_packet); | 565 SignalSentPacket(this, sent_packet); |
566 } | 566 } |
567 | 567 |
568 void DtlsTransportChannelWrapper::OnReadyToSend(TransportChannel* channel) { | 568 void DtlsTransportChannelWrapper::OnReadyToSend(TransportChannel* channel) { |
569 if (writable()) { | 569 if (writable()) { |
570 SignalReadyToSend(this); | 570 SignalReadyToSend(this); |
571 } | 571 } |
572 } | 572 } |
573 | 573 |
574 void DtlsTransportChannelWrapper::OnDtlsEvent(rtc::StreamInterface* dtls, | 574 void DtlsTransportChannelWrapper::OnDtlsEvent(rtc::StreamInterface* dtls, |
575 int sig, int err) { | 575 int sig, int err) { |
576 ASSERT(rtc::Thread::Current() == worker_thread_); | 576 ASSERT(rtc::Thread::Current() == network_thread_); |
577 ASSERT(dtls == dtls_.get()); | 577 ASSERT(dtls == dtls_.get()); |
578 if (sig & rtc::SE_OPEN) { | 578 if (sig & rtc::SE_OPEN) { |
579 // This is the first time. | 579 // This is the first time. |
580 LOG_J(LS_INFO, this) << "DTLS handshake complete."; | 580 LOG_J(LS_INFO, this) << "DTLS handshake complete."; |
581 if (dtls_->GetState() == rtc::SS_OPEN) { | 581 if (dtls_->GetState() == rtc::SS_OPEN) { |
582 // The check for OPEN shouldn't be necessary but let's make | 582 // The check for OPEN shouldn't be necessary but let's make |
583 // sure we don't accidentally frob the state if it's closed. | 583 // sure we don't accidentally frob the state if it's closed. |
584 set_dtls_state(DTLS_TRANSPORT_CONNECTED); | 584 set_dtls_state(DTLS_TRANSPORT_CONNECTED); |
585 set_writable(true); | 585 set_writable(true); |
586 } | 586 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 ASSERT(channel == channel_); | 723 ASSERT(channel == channel_); |
724 SignalStateChanged(this); | 724 SignalStateChanged(this); |
725 } | 725 } |
726 | 726 |
727 void DtlsTransportChannelWrapper::OnDtlsHandshakeError( | 727 void DtlsTransportChannelWrapper::OnDtlsHandshakeError( |
728 rtc::SSLHandshakeError error) { | 728 rtc::SSLHandshakeError error) { |
729 SignalDtlsHandshakeError(error); | 729 SignalDtlsHandshakeError(error); |
730 } | 730 } |
731 | 731 |
732 } // namespace cricket | 732 } // namespace cricket |
OLD | NEW |