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

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

Issue 2970883005: Handle case where UDP packet contains multiple DTLS records. (Closed)
Patch Set: Feedback from Taylor. 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
« no previous file with comments | « no previous file | webrtc/p2p/base/dtlstransportchannel_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // The underlying DTLS stream may have received multiple DTLS records in
542 SignalReadPacket(this, buf, read, rtc::CreatePacketTime(0), 0); 542 // one packet, so read all of them.
543 } else if (ret == rtc::SR_EOS) { 543 do {
544 // Remote peer shut down the association with no error. 544 ret = dtls_->Read(buf, sizeof(buf), &read, &read_error);
545 LOG_J(LS_INFO, this) << "DTLS transport closed"; 545 if (ret == rtc::SR_SUCCESS) {
546 set_writable(false); 546 SignalReadPacket(this, buf, read, rtc::CreatePacketTime(0), 0);
547 set_dtls_state(DTLS_TRANSPORT_CLOSED); 547 } else if (ret == rtc::SR_EOS) {
548 } else if (ret == rtc::SR_ERROR) { 548 // Remote peer shut down the association with no error.
549 // Remote peer shut down the association with an error. 549 LOG_J(LS_INFO, this) << "DTLS transport closed";
550 LOG_J(LS_INFO, this) << "DTLS transport error, code=" << read_error; 550 set_writable(false);
551 set_writable(false); 551 set_dtls_state(DTLS_TRANSPORT_CLOSED);
552 set_dtls_state(DTLS_TRANSPORT_FAILED); 552 } else if (ret == rtc::SR_ERROR) {
553 } 553 // Remote peer shut down the association with an error.
554 LOG_J(LS_INFO, this) << "DTLS transport error, code=" << read_error;
555 set_writable(false);
556 set_dtls_state(DTLS_TRANSPORT_FAILED);
557 }
558 } while (ret == rtc::SR_SUCCESS);
554 } 559 }
555 if (sig & rtc::SE_CLOSE) { 560 if (sig & rtc::SE_CLOSE) {
556 RTC_DCHECK(sig == rtc::SE_CLOSE); // SE_CLOSE should be by itself. 561 RTC_DCHECK(sig == rtc::SE_CLOSE); // SE_CLOSE should be by itself.
557 set_writable(false); 562 set_writable(false);
558 if (!err) { 563 if (!err) {
559 LOG_J(LS_INFO, this) << "DTLS transport closed"; 564 LOG_J(LS_INFO, this) << "DTLS transport closed";
560 set_dtls_state(DTLS_TRANSPORT_CLOSED); 565 set_dtls_state(DTLS_TRANSPORT_CLOSED);
561 } else { 566 } else {
562 LOG_J(LS_INFO, this) << "DTLS transport error, code=" << err; 567 LOG_J(LS_INFO, this) << "DTLS transport error, code=" << err;
563 set_dtls_state(DTLS_TRANSPORT_FAILED); 568 set_dtls_state(DTLS_TRANSPORT_FAILED);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 678
674 dtls_->SetInitialRetransmissionTimeout(initial_timeout); 679 dtls_->SetInitialRetransmissionTimeout(initial_timeout);
675 } else { 680 } else {
676 LOG_J(LS_INFO, this) 681 LOG_J(LS_INFO, this)
677 << "no RTT estimate - using default DTLS handshake timeout"; 682 << "no RTT estimate - using default DTLS handshake timeout";
678 } 683 }
679 } 684 }
680 685
681 686
682 } // namespace cricket 687 } // namespace cricket
OLDNEW
« no previous file with comments | « no previous file | webrtc/p2p/base/dtlstransportchannel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698