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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 // The state transition logic here is as follows: | 414 // The state transition logic here is as follows: |
415 // (1) If we're not doing DTLS-SRTP, then the state is just the | 415 // (1) If we're not doing DTLS-SRTP, then the state is just the |
416 // state of the underlying impl() | 416 // state of the underlying impl() |
417 // (2) If we're doing DTLS-SRTP: | 417 // (2) If we're doing DTLS-SRTP: |
418 // - Prior to the DTLS handshake, the state is neither receiving nor | 418 // - Prior to the DTLS handshake, the state is neither receiving nor |
419 // writable | 419 // writable |
420 // - When the impl goes writable for the first time we | 420 // - When the impl goes writable for the first time we |
421 // start the DTLS handshake | 421 // start the DTLS handshake |
422 // - Once the DTLS handshake completes, the state is that of the | 422 // - Once the DTLS handshake completes, the state is that of the |
423 // impl again | 423 // impl again |
424 void DtlsTransport::OnWritableState(rtc::PacketTransportInterface* transport) { | 424 void DtlsTransport::OnWritableState(rtc::PacketTransportInternal* transport) { |
425 RTC_DCHECK(rtc::Thread::Current() == network_thread_); | 425 RTC_DCHECK(rtc::Thread::Current() == network_thread_); |
426 RTC_DCHECK(transport == ice_transport_); | 426 RTC_DCHECK(transport == ice_transport_); |
427 LOG_J(LS_VERBOSE, this) | 427 LOG_J(LS_VERBOSE, this) |
428 << "DTLSTransportChannelWrapper: ice_transport writable state changed to " | 428 << "DTLSTransportChannelWrapper: ice_transport writable state changed to " |
429 << ice_transport_->writable(); | 429 << ice_transport_->writable(); |
430 | 430 |
431 if (!dtls_active_) { | 431 if (!dtls_active_) { |
432 // Not doing DTLS. | 432 // Not doing DTLS. |
433 // Note: SignalWritableState fired by set_writable. | 433 // Note: SignalWritableState fired by set_writable. |
434 set_writable(ice_transport_->writable()); | 434 set_writable(ice_transport_->writable()); |
(...skipping 11 matching lines...) Expand all Loading... |
446 case DTLS_TRANSPORT_CONNECTING: | 446 case DTLS_TRANSPORT_CONNECTING: |
447 // Do nothing. | 447 // Do nothing. |
448 break; | 448 break; |
449 case DTLS_TRANSPORT_FAILED: | 449 case DTLS_TRANSPORT_FAILED: |
450 case DTLS_TRANSPORT_CLOSED: | 450 case DTLS_TRANSPORT_CLOSED: |
451 // Should not happen. Do nothing. | 451 // Should not happen. Do nothing. |
452 break; | 452 break; |
453 } | 453 } |
454 } | 454 } |
455 | 455 |
456 void DtlsTransport::OnReceivingState(rtc::PacketTransportInterface* transport) { | 456 void DtlsTransport::OnReceivingState(rtc::PacketTransportInternal* transport) { |
457 RTC_DCHECK(rtc::Thread::Current() == network_thread_); | 457 RTC_DCHECK(rtc::Thread::Current() == network_thread_); |
458 RTC_DCHECK(transport == ice_transport_); | 458 RTC_DCHECK(transport == ice_transport_); |
459 LOG_J(LS_VERBOSE, this) << "DTLSTransportChannelWrapper: ice_transport " | 459 LOG_J(LS_VERBOSE, this) << "DTLSTransportChannelWrapper: ice_transport " |
460 "receiving state changed to " | 460 "receiving state changed to " |
461 << ice_transport_->receiving(); | 461 << ice_transport_->receiving(); |
462 if (!dtls_active_ || dtls_state() == DTLS_TRANSPORT_CONNECTED) { | 462 if (!dtls_active_ || dtls_state() == DTLS_TRANSPORT_CONNECTED) { |
463 // Note: SignalReceivingState fired by set_receiving. | 463 // Note: SignalReceivingState fired by set_receiving. |
464 set_receiving(ice_transport_->receiving()); | 464 set_receiving(ice_transport_->receiving()); |
465 } | 465 } |
466 } | 466 } |
467 | 467 |
468 void DtlsTransport::OnReadPacket(rtc::PacketTransportInterface* transport, | 468 void DtlsTransport::OnReadPacket(rtc::PacketTransportInternal* transport, |
469 const char* data, | 469 const char* data, |
470 size_t size, | 470 size_t size, |
471 const rtc::PacketTime& packet_time, | 471 const rtc::PacketTime& packet_time, |
472 int flags) { | 472 int flags) { |
473 RTC_DCHECK(rtc::Thread::Current() == network_thread_); | 473 RTC_DCHECK(rtc::Thread::Current() == network_thread_); |
474 RTC_DCHECK(transport == ice_transport_); | 474 RTC_DCHECK(transport == ice_transport_); |
475 RTC_DCHECK(flags == 0); | 475 RTC_DCHECK(flags == 0); |
476 | 476 |
477 if (!dtls_active_) { | 477 if (!dtls_active_) { |
478 // Not doing DTLS. | 478 // Not doing DTLS. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 SignalReadPacket(this, data, size, packet_time, PF_SRTP_BYPASS); | 536 SignalReadPacket(this, data, size, packet_time, PF_SRTP_BYPASS); |
537 } | 537 } |
538 break; | 538 break; |
539 case DTLS_TRANSPORT_FAILED: | 539 case DTLS_TRANSPORT_FAILED: |
540 case DTLS_TRANSPORT_CLOSED: | 540 case DTLS_TRANSPORT_CLOSED: |
541 // This shouldn't be happening. Drop the packet. | 541 // This shouldn't be happening. Drop the packet. |
542 break; | 542 break; |
543 } | 543 } |
544 } | 544 } |
545 | 545 |
546 void DtlsTransport::OnSentPacket(rtc::PacketTransportInterface* transport, | 546 void DtlsTransport::OnSentPacket(rtc::PacketTransportInternal* transport, |
547 const rtc::SentPacket& sent_packet) { | 547 const rtc::SentPacket& sent_packet) { |
548 RTC_DCHECK(rtc::Thread::Current() == network_thread_); | 548 RTC_DCHECK(rtc::Thread::Current() == network_thread_); |
549 | 549 |
550 SignalSentPacket(this, sent_packet); | 550 SignalSentPacket(this, sent_packet); |
551 } | 551 } |
552 | 552 |
553 void DtlsTransport::OnReadyToSend(rtc::PacketTransportInterface* transport) { | 553 void DtlsTransport::OnReadyToSend(rtc::PacketTransportInternal* transport) { |
554 if (writable()) { | 554 if (writable()) { |
555 SignalReadyToSend(this); | 555 SignalReadyToSend(this); |
556 } | 556 } |
557 } | 557 } |
558 | 558 |
559 void DtlsTransport::OnDtlsEvent(rtc::StreamInterface* dtls, int sig, int err) { | 559 void DtlsTransport::OnDtlsEvent(rtc::StreamInterface* dtls, int sig, int err) { |
560 RTC_DCHECK(rtc::Thread::Current() == network_thread_); | 560 RTC_DCHECK(rtc::Thread::Current() == network_thread_); |
561 RTC_DCHECK(dtls == dtls_.get()); | 561 RTC_DCHECK(dtls == dtls_.get()); |
562 if (sig & rtc::SE_OPEN) { | 562 if (sig & rtc::SE_OPEN) { |
563 // This is the first time. | 563 // This is the first time. |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 << state; | 687 << state; |
688 dtls_state_ = state; | 688 dtls_state_ = state; |
689 SignalDtlsState(this, state); | 689 SignalDtlsState(this, state); |
690 } | 690 } |
691 | 691 |
692 void DtlsTransport::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { | 692 void DtlsTransport::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { |
693 SignalDtlsHandshakeError(error); | 693 SignalDtlsHandshakeError(error); |
694 } | 694 } |
695 | 695 |
696 } // namespace cricket | 696 } // namespace cricket |
OLD | NEW |