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_connection.h" | 5 #include "net/quic/quic_connection.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 | 578 |
579 // Multipath is not enabled, but a packet with multipath flag on is received. | 579 // Multipath is not enabled, but a packet with multipath flag on is received. |
580 if (!multipath_enabled_ && header.public_header.multipath_flag) { | 580 if (!multipath_enabled_ && header.public_header.multipath_flag) { |
581 LOG(DFATAL) << "Received a packet with multipath flag on when multipath is " | 581 LOG(DFATAL) << "Received a packet with multipath flag on when multipath is " |
582 "not enabled."; | 582 "not enabled."; |
583 SendConnectionCloseWithDetails(QUIC_BAD_MULTIPATH_FLAG, | 583 SendConnectionCloseWithDetails(QUIC_BAD_MULTIPATH_FLAG, |
584 "receive a packet with multipath flag on " | 584 "receive a packet with multipath flag on " |
585 "when multipath is not enabled."); | 585 "when multipath is not enabled."); |
586 return false; | 586 return false; |
587 } | 587 } |
| 588 if (!packet_generator_.IsPendingPacketEmpty()) { |
| 589 QUIC_BUG << "Pending frames must be serialized before incoming packets are " |
| 590 << "processed, because that may change a queued ack frame."; |
| 591 SendConnectionCloseWithDetails(QUIC_INTERNAL_ERROR, |
| 592 "Should not process packets while sending."); |
| 593 return false; |
| 594 } |
588 | 595 |
589 // If this packet has already been seen, or the sender has told us that it | 596 // If this packet has already been seen, or the sender has told us that it |
590 // will not be retransmitted, then stop processing the packet. | 597 // will not be retransmitted, then stop processing the packet. |
591 if (!received_packet_manager_.IsAwaitingPacket(header.packet_number)) { | 598 if (!received_packet_manager_.IsAwaitingPacket(header.packet_number)) { |
592 DVLOG(1) << ENDPOINT << "Packet " << header.packet_number | 599 DVLOG(1) << ENDPOINT << "Packet " << header.packet_number |
593 << " no longer being waited for. Discarding."; | 600 << " no longer being waited for. Discarding."; |
594 if (debug_visitor_ != nullptr) { | 601 if (debug_visitor_ != nullptr) { |
595 debug_visitor_->OnDuplicatePacket(header.packet_number); | 602 debug_visitor_->OnDuplicatePacket(header.packet_number); |
596 } | 603 } |
597 ++stats_.packets_dropped; | 604 ++stats_.packets_dropped; |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS, | 1029 QUIC_TOO_MANY_OUTSTANDING_RECEIVED_PACKETS, |
1023 StringPrintf("More than %" PRIu64 " outstanding.", kMaxTrackedPackets)); | 1030 StringPrintf("More than %" PRIu64 " outstanding.", kMaxTrackedPackets)); |
1024 } | 1031 } |
1025 } | 1032 } |
1026 | 1033 |
1027 void QuicConnection::PopulateAckFrame(QuicAckFrame* ack) { | 1034 void QuicConnection::PopulateAckFrame(QuicAckFrame* ack) { |
1028 received_packet_manager_.UpdateReceivedPacketInfo(ack, | 1035 received_packet_manager_.UpdateReceivedPacketInfo(ack, |
1029 clock_->ApproximateNow()); | 1036 clock_->ApproximateNow()); |
1030 } | 1037 } |
1031 | 1038 |
| 1039 const QuicFrame QuicConnection::GetUpdatedAckFrame() { |
| 1040 return received_packet_manager_.GetUpdatedAckFrame(clock_->ApproximateNow()); |
| 1041 } |
| 1042 |
1032 void QuicConnection::PopulateStopWaitingFrame( | 1043 void QuicConnection::PopulateStopWaitingFrame( |
1033 QuicStopWaitingFrame* stop_waiting) { | 1044 QuicStopWaitingFrame* stop_waiting) { |
1034 stop_waiting->least_unacked = GetLeastUnacked(); | 1045 stop_waiting->least_unacked = GetLeastUnacked(); |
1035 stop_waiting->entropy_hash = sent_entropy_manager_.GetCumulativeEntropy( | 1046 stop_waiting->entropy_hash = sent_entropy_manager_.GetCumulativeEntropy( |
1036 stop_waiting->least_unacked - 1); | 1047 stop_waiting->least_unacked - 1); |
1037 } | 1048 } |
1038 | 1049 |
1039 QuicPacketNumber QuicConnection::GetLeastUnacked() const { | 1050 QuicPacketNumber QuicConnection::GetLeastUnacked() const { |
1040 return sent_packet_manager_.GetLeastUnacked(); | 1051 return sent_packet_manager_.GetLeastUnacked(); |
1041 } | 1052 } |
(...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2349 } | 2360 } |
2350 | 2361 |
2351 StringPiece QuicConnection::GetCurrentPacket() { | 2362 StringPiece QuicConnection::GetCurrentPacket() { |
2352 if (current_packet_data_ == nullptr) { | 2363 if (current_packet_data_ == nullptr) { |
2353 return StringPiece(); | 2364 return StringPiece(); |
2354 } | 2365 } |
2355 return StringPiece(current_packet_data_, last_size_); | 2366 return StringPiece(current_packet_data_, last_size_); |
2356 } | 2367 } |
2357 | 2368 |
2358 } // namespace net | 2369 } // namespace net |
OLD | NEW |