Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/quic/quic_packet_creator.h" | 5 #include "net/quic/quic_packet_creator.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "net/quic/crypto/crypto_protocol.h" | |
| 11 #include "net/quic/crypto/quic_random.h" | 12 #include "net/quic/crypto/quic_random.h" |
| 12 #include "net/quic/quic_bug_tracker.h" | 13 #include "net/quic/quic_bug_tracker.h" |
| 13 #include "net/quic/quic_data_writer.h" | 14 #include "net/quic/quic_data_writer.h" |
| 14 #include "net/quic/quic_flags.h" | 15 #include "net/quic/quic_flags.h" |
| 15 #include "net/quic/quic_utils.h" | 16 #include "net/quic/quic_utils.h" |
| 16 | 17 |
| 17 using base::StringPiece; | 18 using base::StringPiece; |
| 18 using std::make_pair; | 19 using std::make_pair; |
| 19 using std::max; | 20 using std::max; |
| 20 using std::min; | 21 using std::min; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 QuicIOVector iov, | 159 QuicIOVector iov, |
| 159 size_t iov_offset, | 160 size_t iov_offset, |
| 160 QuicStreamOffset offset, | 161 QuicStreamOffset offset, |
| 161 bool fin, | 162 bool fin, |
| 162 bool needs_full_padding, | 163 bool needs_full_padding, |
| 163 QuicFrame* frame) { | 164 QuicFrame* frame) { |
| 164 if (!HasRoomForStreamFrame(id, offset)) { | 165 if (!HasRoomForStreamFrame(id, offset)) { |
| 165 return false; | 166 return false; |
| 166 } | 167 } |
| 167 CreateStreamFrame(id, iov, iov_offset, offset, fin, frame); | 168 CreateStreamFrame(id, iov, iov_offset, offset, fin, frame); |
| 169 // Explicitly disallow multi-packet CHLOs. | |
| 170 if (FLAGS_quic_disallow_multi_packet_chlo && id == kCryptoStreamId && | |
| 171 frame->stream_frame->data_length >= sizeof(kCHLO) && | |
| 172 strncmp(frame->stream_frame->data_buffer, | |
| 173 reinterpret_cast<const char*>(&kCHLO), sizeof(kCHLO)) == 0) { | |
| 174 DCHECK_EQ(static_cast<size_t>(0), iov_offset); | |
|
Ryan Hamilton
2016/05/25 02:29:20
nit: instead of static cast, can you just do 0u?
| |
| 175 if (frame->stream_frame->data_length < iov.iov->iov_len) { | |
| 176 const string error_details = "Client hello won't fit in a single packet."; | |
| 177 QUIC_BUG << error_details; | |
| 178 delegate_->OnUnrecoverableError(QUIC_CRYPTO_CHLO_TOO_LARGE, error_details, | |
| 179 ConnectionCloseSource::FROM_SELF); | |
| 180 delete frame->stream_frame; | |
| 181 return false; | |
| 182 } | |
| 183 } | |
| 168 if (!AddFrame(*frame, /*save_retransmittable_frames=*/true)) { | 184 if (!AddFrame(*frame, /*save_retransmittable_frames=*/true)) { |
| 169 // Fails if we try to write unencrypted stream data. | 185 // Fails if we try to write unencrypted stream data. |
| 170 delete frame->stream_frame; | 186 delete frame->stream_frame; |
| 171 return false; | 187 return false; |
| 172 } | 188 } |
| 173 if (needs_full_padding) { | 189 if (needs_full_padding) { |
| 174 packet_.num_padding_bytes = -1; | 190 packet_.num_padding_bytes = -1; |
| 175 } | 191 } |
| 176 return true; | 192 return true; |
| 177 } | 193 } |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 615 // Switching path needs to update packet number length. | 631 // Switching path needs to update packet number length. |
| 616 UpdatePacketNumberLength(least_packet_awaited_by_peer, max_packets_in_flight); | 632 UpdatePacketNumberLength(least_packet_awaited_by_peer, max_packets_in_flight); |
| 617 } | 633 } |
| 618 | 634 |
| 619 bool QuicPacketCreator::IncludeNonceInPublicHeader() { | 635 bool QuicPacketCreator::IncludeNonceInPublicHeader() { |
| 620 return have_diversification_nonce_ && | 636 return have_diversification_nonce_ && |
| 621 packet_.encryption_level == ENCRYPTION_INITIAL; | 637 packet_.encryption_level == ENCRYPTION_INITIAL; |
| 622 } | 638 } |
| 623 | 639 |
| 624 } // namespace net | 640 } // namespace net |
| OLD | NEW |