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_framer.h" | 5 #include "net/quic/quic_framer.h" |
6 | 6 |
7 #include "base/containers/hash_tables.h" | 7 #include "base/containers/hash_tables.h" |
8 #include "net/quic/crypto/quic_decrypter.h" | 8 #include "net/quic/crypto/quic_decrypter.h" |
9 #include "net/quic/crypto/quic_encrypter.h" | 9 #include "net/quic/crypto/quic_encrypter.h" |
10 #include "net/quic/quic_data_reader.h" | 10 #include "net/quic/quic_data_reader.h" |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 } | 254 } |
255 return frame_len; | 255 return frame_len; |
256 } | 256 } |
257 | 257 |
258 QuicFramer::AckFrameInfo::AckFrameInfo() : max_delta(0) { } | 258 QuicFramer::AckFrameInfo::AckFrameInfo() : max_delta(0) { } |
259 | 259 |
260 QuicFramer::AckFrameInfo::~AckFrameInfo() { } | 260 QuicFramer::AckFrameInfo::~AckFrameInfo() { } |
261 | 261 |
262 QuicPacketEntropyHash QuicFramer::GetPacketEntropyHash( | 262 QuicPacketEntropyHash QuicFramer::GetPacketEntropyHash( |
263 const QuicPacketHeader& header) const { | 263 const QuicPacketHeader& header) const { |
264 if (!header.entropy_flag) { | 264 return header.entropy_flag << (header.packet_sequence_number % 8); |
265 // TODO(satyamshekhar): Return some more better value here (something that | |
266 // is not a constant). | |
267 return 0; | |
268 } | |
269 return 1 << (header.packet_sequence_number % 8); | |
270 } | 265 } |
271 | 266 |
272 // Test only. | 267 // Test only. |
273 SerializedPacket QuicFramer::BuildUnsizedDataPacket( | 268 SerializedPacket QuicFramer::BuildUnsizedDataPacket( |
274 const QuicPacketHeader& header, | 269 const QuicPacketHeader& header, |
275 const QuicFrames& frames) { | 270 const QuicFrames& frames) { |
276 const size_t max_plaintext_size = GetMaxPlaintextSize(kMaxPacketSize); | 271 const size_t max_plaintext_size = GetMaxPlaintextSize(kMaxPacketSize); |
277 size_t packet_size = GetPacketHeaderSize(header); | 272 size_t packet_size = GetPacketHeaderSize(header); |
278 for (size_t i = 0; i < frames.size(); ++i) { | 273 for (size_t i = 0; i < frames.size(); ++i) { |
279 DCHECK_LE(packet_size, max_plaintext_size); | 274 DCHECK_LE(packet_size, max_plaintext_size); |
(...skipping 1536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1816 // Determine whether we need to truncate ranges. | 1811 // Determine whether we need to truncate ranges. |
1817 size_t available_range_bytes = writer->capacity() - writer->length() - | 1812 size_t available_range_bytes = writer->capacity() - writer->length() - |
1818 GetMinAckFrameSize(quic_version_, | 1813 GetMinAckFrameSize(quic_version_, |
1819 header.public_header.sequence_number_length, | 1814 header.public_header.sequence_number_length, |
1820 largest_observed_length); | 1815 largest_observed_length); |
1821 size_t max_num_ranges = available_range_bytes / | 1816 size_t max_num_ranges = available_range_bytes / |
1822 (missing_sequence_number_length + PACKET_1BYTE_SEQUENCE_NUMBER); | 1817 (missing_sequence_number_length + PACKET_1BYTE_SEQUENCE_NUMBER); |
1823 max_num_ranges = | 1818 max_num_ranges = |
1824 min(static_cast<size_t>(numeric_limits<uint8>::max()), max_num_ranges); | 1819 min(static_cast<size_t>(numeric_limits<uint8>::max()), max_num_ranges); |
1825 bool truncated = ack_info.nack_ranges.size() > max_num_ranges; | 1820 bool truncated = ack_info.nack_ranges.size() > max_num_ranges; |
1826 DLOG_IF(INFO, truncated) << "Truncating ack from " | 1821 DVLOG_IF(1, truncated) << "Truncating ack from " |
1827 << ack_info.nack_ranges.size() << " ranges to " | 1822 << ack_info.nack_ranges.size() << " ranges to " |
1828 << max_num_ranges; | 1823 << max_num_ranges; |
1829 | 1824 |
1830 // Write out the type byte by setting the low order bits and doing shifts | 1825 // Write out the type byte by setting the low order bits and doing shifts |
1831 // to make room for the next bit flags to be set. | 1826 // to make room for the next bit flags to be set. |
1832 // Whether there are any nacks. | 1827 // Whether there are any nacks. |
1833 uint8 type_byte = ack_info.nack_ranges.empty() ? 0 : kQuicHasNacksMask; | 1828 uint8 type_byte = ack_info.nack_ranges.empty() ? 0 : kQuicHasNacksMask; |
1834 | 1829 |
1835 // truncating bit. | 1830 // truncating bit. |
1836 type_byte <<= kQuicAckTruncatedShift; | 1831 type_byte <<= kQuicAckTruncatedShift; |
1837 type_byte |= truncated ? kQuicAckTruncatedMask : 0; | 1832 type_byte |= truncated ? kQuicAckTruncatedMask : 0; |
1838 | 1833 |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2076 | 2071 |
2077 bool QuicFramer::RaiseError(QuicErrorCode error) { | 2072 bool QuicFramer::RaiseError(QuicErrorCode error) { |
2078 DVLOG(1) << detailed_error_; | 2073 DVLOG(1) << detailed_error_; |
2079 set_error(error); | 2074 set_error(error); |
2080 visitor_->OnError(this); | 2075 visitor_->OnError(this); |
2081 reader_.reset(NULL); | 2076 reader_.reset(NULL); |
2082 return false; | 2077 return false; |
2083 } | 2078 } |
2084 | 2079 |
2085 } // namespace net | 2080 } // namespace net |
OLD | NEW |