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

Unified Diff: webrtc/p2p/base/dtlstransportchannel.cc

Issue 1912323002: Cache a ClientHello received before the DTLS handshake has started. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/p2p/base/dtlstransportchannel.cc
diff --git a/webrtc/p2p/base/dtlstransportchannel.cc b/webrtc/p2p/base/dtlstransportchannel.cc
index 88a11928cc205aebaf5cde89a8d5d7606cc57caf..51f1429ee86aa89ce410214329a39b0b3c0be3e8 100644
--- a/webrtc/p2p/base/dtlstransportchannel.cc
+++ b/webrtc/p2p/base/dtlstransportchannel.cc
@@ -469,15 +469,18 @@ void DtlsTransportChannelWrapper::OnReadPacket(
switch (dtls_state()) {
case DTLS_TRANSPORT_NEW:
if (dtls_) {
- // Drop packets received before DTLS has actually started.
- LOG_J(LS_INFO, this) << "Dropping packet received before DTLS started.";
+ LOG_J(LS_INFO, this) << "Packet received before DTLS started.";
} else {
- // Currently drop the packet, but we might in future
- // decide to take this as evidence that the other
- // side is ready to do DTLS and start the handshake
- // on our end.
- LOG_J(LS_WARNING, this) << "Received packet before we know if we are "
- << "doing DTLS or not; dropping.";
+ LOG_J(LS_WARNING, this) << "Packet received before we know if we are "
+ << "doing DTLS or not.";
+ }
+ // Cache the last DTLS packet (should be a client hello) received before
+ // DTLS has actually started.
+ if (IsDtlsPacket(data, size)) {
juberti2 2016/04/25 20:40:18 We should probably also verify this is a CLIENT HE
Taylor Brandstetter 2016/04/26 22:55:58 Done.
+ LOG_J(LS_INFO, this) << "Caching DTLS packet until DTLS is started.";
+ cached_dtls_packet_.SetData(data, size);
+ } else {
+ LOG_J(LS_INFO, this) << "Not a DTLS packet; dropping.";
}
break;
@@ -576,6 +579,21 @@ bool DtlsTransportChannelWrapper::MaybeStartDtls() {
LOG_J(LS_INFO, this)
<< "DtlsTransportChannelWrapper: Started DTLS handshake";
set_dtls_state(DTLS_TRANSPORT_CONNECTING);
+ // Now that the handshake has started, we can process a cached packet
+ // (if one exists).
+ if (cached_dtls_packet_.size()) {
+ if (ssl_role_ == rtc::SSL_SERVER) {
+ LOG_J(LS_INFO, this) << "Handling cached DTLS packet.";
+ if (!HandleDtlsPacket(cached_dtls_packet_.data<char>(),
+ cached_dtls_packet_.size())) {
+ LOG_J(LS_ERROR, this) << "Failed to handle DTLS packet.";
+ }
+ } else {
+ LOG_J(LS_WARNING, this) << "Discarding cached DTLS packet because "
juberti2 2016/04/25 20:40:18 Log text could be clearer to indicate this is a re
Taylor Brandstetter 2016/04/26 22:55:58 Now that the message is changed to "discarding cac
+ << "we don't have the server role.";
+ }
+ cached_dtls_packet_.Clear();
+ }
}
return true;
}
« webrtc/p2p/base/dtlstransportchannel.h ('K') | « webrtc/p2p/base/dtlstransportchannel.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698