| 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/core/quic_packet_creator.h" | 5 #include "net/quic/core/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" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 if (length == 0 || ++iovnum >= iov.iov_count) { | 265 if (length == 0 || ++iovnum >= iov.iov_count) { |
| 266 break; | 266 break; |
| 267 } | 267 } |
| 268 src = static_cast<char*>(iov.iov[iovnum].iov_base); | 268 src = static_cast<char*>(iov.iov[iovnum].iov_base); |
| 269 copy_len = min(length, iov.iov[iovnum].iov_len); | 269 copy_len = min(length, iov.iov[iovnum].iov_len); |
| 270 } | 270 } |
| 271 QUIC_BUG_IF(length > 0) << "Failed to copy entire length to buffer."; | 271 QUIC_BUG_IF(length > 0) << "Failed to copy entire length to buffer."; |
| 272 } | 272 } |
| 273 | 273 |
| 274 void QuicPacketCreator::ReserializeAllFrames( | 274 void QuicPacketCreator::ReserializeAllFrames( |
| 275 const PendingRetransmission& retransmission, | 275 const QuicPendingRetransmission& retransmission, |
| 276 char* buffer, | 276 char* buffer, |
| 277 size_t buffer_len) { | 277 size_t buffer_len) { |
| 278 DCHECK(queued_frames_.empty()); | 278 DCHECK(queued_frames_.empty()); |
| 279 DCHECK_EQ(0, packet_.num_padding_bytes); | 279 DCHECK_EQ(0, packet_.num_padding_bytes); |
| 280 QUIC_BUG_IF(retransmission.retransmittable_frames.empty()) | 280 QUIC_BUG_IF(retransmission.retransmittable_frames.empty()) |
| 281 << "Attempt to serialize empty packet"; | 281 << "Attempt to serialize empty packet"; |
| 282 const EncryptionLevel default_encryption_level = packet_.encryption_level; | 282 const EncryptionLevel default_encryption_level = packet_.encryption_level; |
| 283 | 283 |
| 284 // Temporarily set the packet number length and change the encryption level. | 284 // Temporarily set the packet number length and change the encryption level. |
| 285 packet_.packet_number_length = retransmission.packet_number_length; | 285 packet_.packet_number_length = retransmission.packet_number_length; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 const string error_details = "Failed to SerializePacket."; | 328 const string error_details = "Failed to SerializePacket."; |
| 329 QUIC_BUG << error_details; | 329 QUIC_BUG << error_details; |
| 330 delegate_->OnUnrecoverableError(QUIC_FAILED_TO_SERIALIZE_PACKET, | 330 delegate_->OnUnrecoverableError(QUIC_FAILED_TO_SERIALIZE_PACKET, |
| 331 error_details, | 331 error_details, |
| 332 ConnectionCloseSource::FROM_SELF); | 332 ConnectionCloseSource::FROM_SELF); |
| 333 return; | 333 return; |
| 334 } | 334 } |
| 335 | 335 |
| 336 delegate_->OnSerializedPacket(&packet_); | 336 delegate_->OnSerializedPacket(&packet_); |
| 337 ClearPacket(); | 337 ClearPacket(); |
| 338 // Maximum packet size may be only enacted while no packet is currently being | |
| 339 // constructed, so here we have a good opportunity to actually change it. | |
| 340 if (CanSetMaxPacketLength()) { | |
| 341 SetMaxPacketLength(max_packet_length_); | |
| 342 } | |
| 343 } | 338 } |
| 344 | 339 |
| 345 void QuicPacketCreator::ClearPacket() { | 340 void QuicPacketCreator::ClearPacket() { |
| 346 packet_.has_ack = false; | 341 packet_.has_ack = false; |
| 347 packet_.has_stop_waiting = false; | 342 packet_.has_stop_waiting = false; |
| 348 packet_.has_crypto_handshake = NOT_HANDSHAKE; | 343 packet_.has_crypto_handshake = NOT_HANDSHAKE; |
| 349 packet_.num_padding_bytes = 0; | 344 packet_.num_padding_bytes = 0; |
| 350 packet_.original_path_id = kInvalidPathId; | 345 packet_.original_path_id = kInvalidPathId; |
| 351 packet_.original_packet_number = 0; | 346 packet_.original_packet_number = 0; |
| 352 packet_.transmission_type = NOT_RETRANSMISSION; | 347 packet_.transmission_type = NOT_RETRANSMISSION; |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 // Switching path needs to update packet number length. | 659 // Switching path needs to update packet number length. |
| 665 UpdatePacketNumberLength(least_packet_awaited_by_peer, max_packets_in_flight); | 660 UpdatePacketNumberLength(least_packet_awaited_by_peer, max_packets_in_flight); |
| 666 } | 661 } |
| 667 | 662 |
| 668 bool QuicPacketCreator::IncludeNonceInPublicHeader() { | 663 bool QuicPacketCreator::IncludeNonceInPublicHeader() { |
| 669 return have_diversification_nonce_ && | 664 return have_diversification_nonce_ && |
| 670 packet_.encryption_level == ENCRYPTION_INITIAL; | 665 packet_.encryption_level == ENCRYPTION_INITIAL; |
| 671 } | 666 } |
| 672 | 667 |
| 673 } // namespace net | 668 } // namespace net |
| OLD | NEW |