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" |
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 default: | 971 default: |
972 LOG(DFATAL) << "Unreachable case statement."; | 972 LOG(DFATAL) << "Unreachable case statement."; |
973 return PACKET_FLAGS_6BYTE_SEQUENCE; | 973 return PACKET_FLAGS_6BYTE_SEQUENCE; |
974 } | 974 } |
975 } | 975 } |
976 | 976 |
977 // static | 977 // static |
978 QuicFramer::AckFrameInfo QuicFramer::GetAckFrameInfo( | 978 QuicFramer::AckFrameInfo QuicFramer::GetAckFrameInfo( |
979 const QuicAckFrame& frame) { | 979 const QuicAckFrame& frame) { |
980 AckFrameInfo ack_info; | 980 AckFrameInfo ack_info; |
981 if (!frame.missing_packets.empty()) { | 981 if (frame.missing_packets.empty()) { |
982 DCHECK_GE(frame.largest_observed, *frame.missing_packets.rbegin()); | 982 return ack_info; |
983 size_t cur_range_length = 0; | 983 } |
984 SequenceNumberSet::const_iterator iter = frame.missing_packets.begin(); | 984 DCHECK_GE(frame.largest_observed, *frame.missing_packets.rbegin()); |
985 QuicPacketSequenceNumber last_missing = *iter; | 985 size_t cur_range_length = 0; |
986 ++iter; | 986 SequenceNumberSet::const_iterator iter = frame.missing_packets.begin(); |
987 for (; iter != frame.missing_packets.end(); ++iter) { | 987 QuicPacketSequenceNumber last_missing = *iter; |
988 if (cur_range_length != numeric_limits<uint8>::max() && | 988 ++iter; |
989 *iter == (last_missing + 1)) { | 989 for (; iter != frame.missing_packets.end(); ++iter) { |
990 ++cur_range_length; | 990 if (cur_range_length != numeric_limits<uint8>::max() && |
991 } else { | 991 *iter == (last_missing + 1)) { |
992 ack_info.nack_ranges[last_missing - cur_range_length] = | 992 ++cur_range_length; |
993 cur_range_length; | 993 } else { |
994 cur_range_length = 0; | 994 ack_info.nack_ranges[last_missing - cur_range_length] = cur_range_length; |
995 } | 995 cur_range_length = 0; |
996 ack_info.max_delta = max(ack_info.max_delta, *iter - last_missing); | |
997 last_missing = *iter; | |
998 } | 996 } |
999 // Include the last nack range. | 997 ack_info.max_delta = max(ack_info.max_delta, *iter - last_missing); |
1000 ack_info.nack_ranges[last_missing - cur_range_length] = cur_range_length; | 998 last_missing = *iter; |
1001 // Include the range to the largest observed. | |
1002 ack_info.max_delta = max(ack_info.max_delta, | |
1003 frame.largest_observed - last_missing); | |
1004 } | 999 } |
| 1000 // Include the last nack range. |
| 1001 ack_info.nack_ranges[last_missing - cur_range_length] = cur_range_length; |
| 1002 // Include the range to the largest observed. |
| 1003 ack_info.max_delta = |
| 1004 max(ack_info.max_delta, frame.largest_observed - last_missing); |
1005 return ack_info; | 1005 return ack_info; |
1006 } | 1006 } |
1007 | 1007 |
1008 bool QuicFramer::ProcessPacketHeader( | 1008 bool QuicFramer::ProcessPacketHeader( |
1009 QuicPacketHeader* header, | 1009 QuicPacketHeader* header, |
1010 const QuicEncryptedPacket& packet) { | 1010 const QuicEncryptedPacket& packet) { |
1011 if (!ProcessPacketSequenceNumber(header->public_header.sequence_number_length, | 1011 if (!ProcessPacketSequenceNumber(header->public_header.sequence_number_length, |
1012 &header->packet_sequence_number)) { | 1012 &header->packet_sequence_number)) { |
1013 set_detailed_error("Unable to read sequence number."); | 1013 set_detailed_error("Unable to read sequence number."); |
1014 return RaiseError(QUIC_INVALID_PACKET_HEADER); | 1014 return RaiseError(QUIC_INVALID_PACKET_HEADER); |
(...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2315 | 2315 |
2316 bool QuicFramer::RaiseError(QuicErrorCode error) { | 2316 bool QuicFramer::RaiseError(QuicErrorCode error) { |
2317 DVLOG(1) << "Error detail: " << detailed_error_; | 2317 DVLOG(1) << "Error detail: " << detailed_error_; |
2318 set_error(error); | 2318 set_error(error); |
2319 visitor_->OnError(this); | 2319 visitor_->OnError(this); |
2320 reader_.reset(nullptr); | 2320 reader_.reset(nullptr); |
2321 return false; | 2321 return false; |
2322 } | 2322 } |
2323 | 2323 |
2324 } // namespace net | 2324 } // namespace net |
OLD | NEW |