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 "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "net/quic/crypto/crypto_framer.h" | 9 #include "net/quic/crypto/crypto_framer.h" |
10 #include "net/quic/crypto/crypto_handshake_message.h" | 10 #include "net/quic/crypto/crypto_handshake_message.h" |
11 #include "net/quic/crypto/crypto_protocol.h" | 11 #include "net/quic/crypto/crypto_protocol.h" |
12 #include "net/quic/crypto/quic_decrypter.h" | 12 #include "net/quic/crypto/quic_decrypter.h" |
13 #include "net/quic/crypto/quic_encrypter.h" | 13 #include "net/quic/crypto/quic_encrypter.h" |
14 #include "net/quic/quic_data_reader.h" | 14 #include "net/quic/quic_data_reader.h" |
15 #include "net/quic/quic_data_writer.h" | 15 #include "net/quic/quic_data_writer.h" |
16 #include "net/quic/quic_flags.h" | 16 #include "net/quic/quic_flags.h" |
17 #include "net/quic/quic_socket_address_coder.h" | 17 #include "net/quic/quic_socket_address_coder.h" |
18 | 18 |
19 using base::StringPiece; | 19 using base::StringPiece; |
20 using std::make_pair; | |
21 using std::map; | 20 using std::map; |
22 using std::max; | 21 using std::max; |
23 using std::min; | 22 using std::min; |
24 using std::numeric_limits; | 23 using std::numeric_limits; |
25 using std::string; | 24 using std::string; |
26 | 25 |
27 namespace net { | 26 namespace net { |
28 | 27 |
29 namespace { | 28 namespace { |
30 | 29 |
(...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1400 // Time delta from the framer creation. | 1399 // Time delta from the framer creation. |
1401 uint32 time_delta_us; | 1400 uint32 time_delta_us; |
1402 if (!reader_->ReadBytes(&time_delta_us, sizeof(time_delta_us))) { | 1401 if (!reader_->ReadBytes(&time_delta_us, sizeof(time_delta_us))) { |
1403 set_detailed_error("Unable to read time delta in received packets."); | 1402 set_detailed_error("Unable to read time delta in received packets."); |
1404 return false; | 1403 return false; |
1405 } | 1404 } |
1406 | 1405 |
1407 last_timestamp_ = CalculateTimestampFromWire(time_delta_us); | 1406 last_timestamp_ = CalculateTimestampFromWire(time_delta_us); |
1408 | 1407 |
1409 ack_frame->received_packet_times.push_back( | 1408 ack_frame->received_packet_times.push_back( |
1410 make_pair(seq_num, creation_time_.Add(last_timestamp_))); | 1409 std::make_pair(seq_num, creation_time_.Add(last_timestamp_))); |
1411 | 1410 |
1412 for (uint8 i = 1; i < num_received_packets; ++i) { | 1411 for (uint8 i = 1; i < num_received_packets; ++i) { |
1413 if (!reader_->ReadBytes(&delta_from_largest_observed, | 1412 if (!reader_->ReadBytes(&delta_from_largest_observed, |
1414 PACKET_1BYTE_SEQUENCE_NUMBER)) { | 1413 PACKET_1BYTE_SEQUENCE_NUMBER)) { |
1415 set_detailed_error( | 1414 set_detailed_error( |
1416 "Unable to read sequence delta in received packets."); | 1415 "Unable to read sequence delta in received packets."); |
1417 return false; | 1416 return false; |
1418 } | 1417 } |
1419 seq_num = ack_frame->largest_observed - delta_from_largest_observed; | 1418 seq_num = ack_frame->largest_observed - delta_from_largest_observed; |
1420 | 1419 |
1421 // Time delta from the previous timestamp. | 1420 // Time delta from the previous timestamp. |
1422 uint64 incremental_time_delta_us; | 1421 uint64 incremental_time_delta_us; |
1423 if (!reader_->ReadUFloat16(&incremental_time_delta_us)) { | 1422 if (!reader_->ReadUFloat16(&incremental_time_delta_us)) { |
1424 set_detailed_error( | 1423 set_detailed_error( |
1425 "Unable to read incremental time delta in received packets."); | 1424 "Unable to read incremental time delta in received packets."); |
1426 return false; | 1425 return false; |
1427 } | 1426 } |
1428 | 1427 |
1429 last_timestamp_ = last_timestamp_.Add( | 1428 last_timestamp_ = last_timestamp_.Add( |
1430 QuicTime::Delta::FromMicroseconds(incremental_time_delta_us)); | 1429 QuicTime::Delta::FromMicroseconds(incremental_time_delta_us)); |
1431 ack_frame->received_packet_times.push_back( | 1430 ack_frame->received_packet_times.push_back( |
1432 make_pair(seq_num, creation_time_.Add(last_timestamp_))); | 1431 std::make_pair(seq_num, creation_time_.Add(last_timestamp_))); |
1433 } | 1432 } |
1434 } | 1433 } |
1435 } | 1434 } |
1436 return true; | 1435 return true; |
1437 } | 1436 } |
1438 | 1437 |
1439 bool QuicFramer::ProcessStopWaitingFrame(const QuicPacketHeader& header, | 1438 bool QuicFramer::ProcessStopWaitingFrame(const QuicPacketHeader& header, |
1440 QuicStopWaitingFrame* stop_waiting) { | 1439 QuicStopWaitingFrame* stop_waiting) { |
1441 if (!reader_->ReadBytes(&stop_waiting->entropy_hash, 1)) { | 1440 if (!reader_->ReadBytes(&stop_waiting->entropy_hash, 1)) { |
1442 set_detailed_error("Unable to read entropy hash for sent packets."); | 1441 set_detailed_error("Unable to read entropy hash for sent packets."); |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2214 | 2213 |
2215 bool QuicFramer::RaiseError(QuicErrorCode error) { | 2214 bool QuicFramer::RaiseError(QuicErrorCode error) { |
2216 DVLOG(1) << "Error detail: " << detailed_error_; | 2215 DVLOG(1) << "Error detail: " << detailed_error_; |
2217 set_error(error); | 2216 set_error(error); |
2218 visitor_->OnError(this); | 2217 visitor_->OnError(this); |
2219 reader_.reset(nullptr); | 2218 reader_.reset(nullptr); |
2220 return false; | 2219 return false; |
2221 } | 2220 } |
2222 | 2221 |
2223 } // namespace net | 2222 } // namespace net |
OLD | NEW |