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 #include <algorithm> | 9 #include <algorithm> |
10 #include <iterator> | 10 #include <iterator> |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 | 361 |
362 bool QuicConnection::OnUnauthenticatedHeader(const QuicPacketHeader& header) { | 362 bool QuicConnection::OnUnauthenticatedHeader(const QuicPacketHeader& header) { |
363 return true; | 363 return true; |
364 } | 364 } |
365 | 365 |
366 bool QuicConnection::OnPacketHeader(const QuicPacketHeader& header) { | 366 bool QuicConnection::OnPacketHeader(const QuicPacketHeader& header) { |
367 if (debug_visitor_) { | 367 if (debug_visitor_) { |
368 debug_visitor_->OnPacketHeader(header); | 368 debug_visitor_->OnPacketHeader(header); |
369 } | 369 } |
370 | 370 |
| 371 if (header.fec_flag && framer_.version() <= QUIC_VERSION_14) { |
| 372 DLOG(WARNING) << "Ignoring FEC packets for versions prior to 15."; |
| 373 return false; |
| 374 } |
| 375 |
371 if (!ProcessValidatedPacket()) { | 376 if (!ProcessValidatedPacket()) { |
372 return false; | 377 return false; |
373 } | 378 } |
374 | 379 |
375 // Will be decrement below if we fall through to return true; | 380 // Will be decrement below if we fall through to return true; |
376 ++stats_.packets_dropped; | 381 ++stats_.packets_dropped; |
377 | 382 |
378 if (header.public_header.guid != guid_) { | 383 if (header.public_header.guid != guid_) { |
379 DVLOG(1) << ENDPOINT << "Ignoring packet from unexpected GUID: " | 384 DVLOG(1) << ENDPOINT << "Ignoring packet from unexpected GUID: " |
380 << header.public_header.guid << " instead of " << guid_; | 385 << header.public_header.guid << " instead of " << guid_; |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 } | 572 } |
568 | 573 |
569 if (!sent_entropy_manager_.IsValidEntropy( | 574 if (!sent_entropy_manager_.IsValidEntropy( |
570 incoming_ack.received_info.largest_observed, | 575 incoming_ack.received_info.largest_observed, |
571 incoming_ack.received_info.missing_packets, | 576 incoming_ack.received_info.missing_packets, |
572 incoming_ack.received_info.entropy_hash)) { | 577 incoming_ack.received_info.entropy_hash)) { |
573 DLOG(ERROR) << ENDPOINT << "Peer sent invalid entropy."; | 578 DLOG(ERROR) << ENDPOINT << "Peer sent invalid entropy."; |
574 return false; | 579 return false; |
575 } | 580 } |
576 | 581 |
| 582 for (SequenceNumberSet::const_iterator iter = |
| 583 incoming_ack.received_info.revived_packets.begin(); |
| 584 iter != incoming_ack.received_info.revived_packets.end(); ++iter) { |
| 585 if (!ContainsKey(incoming_ack.received_info.missing_packets, *iter)) { |
| 586 DLOG(ERROR) << ENDPOINT |
| 587 << "Peer specified revived packet which was not missing."; |
| 588 return false; |
| 589 } |
| 590 } |
577 return true; | 591 return true; |
578 } | 592 } |
579 | 593 |
580 void QuicConnection::OnFecData(const QuicFecData& fec) { | 594 void QuicConnection::OnFecData(const QuicFecData& fec) { |
581 DCHECK_EQ(IN_FEC_GROUP, last_header_.is_in_fec_group); | 595 DCHECK_EQ(IN_FEC_GROUP, last_header_.is_in_fec_group); |
582 DCHECK_NE(0u, last_header_.fec_group); | 596 DCHECK_NE(0u, last_header_.fec_group); |
583 QuicFecGroup* group = GetFecGroup(); | 597 QuicFecGroup* group = GetFecGroup(); |
584 if (group != NULL) { | 598 if (group != NULL) { |
585 group->UpdateFec(last_header_.packet_sequence_number, fec); | 599 group->UpdateFec(last_header_.packet_sequence_number, fec); |
586 } | 600 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 << " stream frames for " << last_header_.public_header.guid; | 651 << " stream frames for " << last_header_.public_header.guid; |
638 | 652 |
639 MaybeQueueAck(); | 653 MaybeQueueAck(); |
640 | 654 |
641 // Discard the packet if the visitor fails to process the stream frames. | 655 // Discard the packet if the visitor fails to process the stream frames. |
642 if (!last_stream_frames_.empty() && | 656 if (!last_stream_frames_.empty() && |
643 !visitor_->OnStreamFrames(last_stream_frames_)) { | 657 !visitor_->OnStreamFrames(last_stream_frames_)) { |
644 return; | 658 return; |
645 } | 659 } |
646 | 660 |
647 received_packet_manager_.RecordPacketReceived(last_size_, | 661 if (last_packet_revived_) { |
648 last_header_, | 662 received_packet_manager_.RecordPacketRevived( |
649 time_of_last_received_packet_, | 663 last_header_.packet_sequence_number); |
650 last_packet_revived_); | 664 } else { |
| 665 received_packet_manager_.RecordPacketReceived( |
| 666 last_size_, last_header_, time_of_last_received_packet_); |
| 667 } |
651 for (size_t i = 0; i < last_stream_frames_.size(); ++i) { | 668 for (size_t i = 0; i < last_stream_frames_.size(); ++i) { |
652 stats_.stream_bytes_received += | 669 stats_.stream_bytes_received += |
653 last_stream_frames_[i].data.TotalBufferSize(); | 670 last_stream_frames_[i].data.TotalBufferSize(); |
654 } | 671 } |
655 | 672 |
656 // Process stream resets, then acks, then congestion feedback. | 673 // Process stream resets, then acks, then congestion feedback. |
657 for (size_t i = 0; i < last_goaway_frames_.size(); ++i) { | 674 for (size_t i = 0; i < last_goaway_frames_.size(); ++i) { |
658 visitor_->OnGoAway(last_goaway_frames_[i]); | 675 visitor_->OnGoAway(last_goaway_frames_[i]); |
659 } | 676 } |
660 for (size_t i = 0; i < last_rst_frames_.size(); ++i) { | 677 for (size_t i = 0; i < last_rst_frames_.size(); ++i) { |
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1664 // If we changed the generator's batch state, restore original batch state. | 1681 // If we changed the generator's batch state, restore original batch state. |
1665 if (!already_in_batch_mode_) { | 1682 if (!already_in_batch_mode_) { |
1666 DVLOG(1) << "Leaving Batch Mode."; | 1683 DVLOG(1) << "Leaving Batch Mode."; |
1667 connection_->packet_generator_.FinishBatchOperations(); | 1684 connection_->packet_generator_.FinishBatchOperations(); |
1668 } | 1685 } |
1669 DCHECK_EQ(already_in_batch_mode_, | 1686 DCHECK_EQ(already_in_batch_mode_, |
1670 connection_->packet_generator_.InBatchMode()); | 1687 connection_->packet_generator_.InBatchMode()); |
1671 } | 1688 } |
1672 | 1689 |
1673 } // namespace net | 1690 } // namespace net |
OLD | NEW |