Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Side by Side Diff: webrtc/p2p/base/dtlstransportchannel.cc

Issue 2970883005: Handle case where UDP packet contains multiple DTLS records. (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 // The check for OPEN shouldn't be necessary but let's make 530 // The check for OPEN shouldn't be necessary but let's make
531 // sure we don't accidentally frob the state if it's closed. 531 // sure we don't accidentally frob the state if it's closed.
532 set_dtls_state(DTLS_TRANSPORT_CONNECTED); 532 set_dtls_state(DTLS_TRANSPORT_CONNECTED);
533 set_writable(true); 533 set_writable(true);
534 } 534 }
535 } 535 }
536 if (sig & rtc::SE_READ) { 536 if (sig & rtc::SE_READ) {
537 char buf[kMaxDtlsPacketLen]; 537 char buf[kMaxDtlsPacketLen];
538 size_t read; 538 size_t read;
539 int read_error; 539 int read_error;
540 rtc::StreamResult ret = dtls_->Read(buf, sizeof(buf), &read, &read_error); 540 rtc::StreamResult ret;
541 if (ret == rtc::SR_SUCCESS) { 541 do {
Taylor Brandstetter 2017/07/06 22:06:11 Could use a comment explaining why this is done in
joachim 2017/07/07 16:12:59 Done.
542 SignalReadPacket(this, buf, read, rtc::CreatePacketTime(0), 0); 542 ret = dtls_->Read(buf, sizeof(buf), &read, &read_error);
543 } else if (ret == rtc::SR_EOS) { 543 if (ret == rtc::SR_SUCCESS) {
544 // Remote peer shut down the association with no error. 544 SignalReadPacket(this, buf, read, rtc::CreatePacketTime(0), 0);
545 LOG_J(LS_INFO, this) << "DTLS transport closed"; 545 } else if (ret == rtc::SR_EOS) {
546 set_writable(false); 546 // Remote peer shut down the association with no error.
547 set_dtls_state(DTLS_TRANSPORT_CLOSED); 547 LOG_J(LS_INFO, this) << "DTLS transport closed";
548 } else if (ret == rtc::SR_ERROR) { 548 set_writable(false);
549 // Remote peer shut down the association with an error. 549 set_dtls_state(DTLS_TRANSPORT_CLOSED);
550 LOG_J(LS_INFO, this) << "DTLS transport error, code=" << read_error; 550 } else if (ret == rtc::SR_ERROR) {
551 set_writable(false); 551 // Remote peer shut down the association with an error.
552 set_dtls_state(DTLS_TRANSPORT_FAILED); 552 LOG_J(LS_INFO, this) << "DTLS transport error, code=" << read_error;
553 } 553 set_writable(false);
554 set_dtls_state(DTLS_TRANSPORT_FAILED);
555 }
556 } while (ret == rtc::SR_SUCCESS);
554 } 557 }
555 if (sig & rtc::SE_CLOSE) { 558 if (sig & rtc::SE_CLOSE) {
556 RTC_DCHECK(sig == rtc::SE_CLOSE); // SE_CLOSE should be by itself. 559 RTC_DCHECK(sig == rtc::SE_CLOSE); // SE_CLOSE should be by itself.
557 set_writable(false); 560 set_writable(false);
558 if (!err) { 561 if (!err) {
559 LOG_J(LS_INFO, this) << "DTLS transport closed"; 562 LOG_J(LS_INFO, this) << "DTLS transport closed";
560 set_dtls_state(DTLS_TRANSPORT_CLOSED); 563 set_dtls_state(DTLS_TRANSPORT_CLOSED);
561 } else { 564 } else {
562 LOG_J(LS_INFO, this) << "DTLS transport error, code=" << err; 565 LOG_J(LS_INFO, this) << "DTLS transport error, code=" << err;
563 set_dtls_state(DTLS_TRANSPORT_FAILED); 566 set_dtls_state(DTLS_TRANSPORT_FAILED);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 676
674 dtls_->SetInitialRetransmissionTimeout(initial_timeout); 677 dtls_->SetInitialRetransmissionTimeout(initial_timeout);
675 } else { 678 } else {
676 LOG_J(LS_INFO, this) 679 LOG_J(LS_INFO, this)
677 << "no RTT estimate - using default DTLS handshake timeout"; 680 << "no RTT estimate - using default DTLS handshake timeout";
678 } 681 }
679 } 682 }
680 683
681 684
682 } // namespace cricket 685 } // namespace cricket
OLDNEW
« no previous file with comments | « no previous file | webrtc/p2p/base/dtlstransportchannel_unittest.cc » ('j') | webrtc/p2p/base/dtlstransportchannel_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698