| 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 // The entity that handles framing writes for a Quic client or server. | 5 // The entity that handles framing writes for a Quic client or server. |
| 6 // Each QuicSession will have a connection associated with it. | 6 // Each QuicSession will have a connection associated with it. |
| 7 // | 7 // |
| 8 // On the server side, the Dispatcher handles the raw reads, and hands off | 8 // On the server side, the Dispatcher handles the raw reads, and hands off |
| 9 // packets via ProcessUdpPacket for framing and processing. | 9 // packets via ProcessUdpPacket for framing and processing. |
| 10 // | 10 // |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 const QuicVersionVector& server_supported_versions() const { | 472 const QuicVersionVector& server_supported_versions() const { |
| 473 DCHECK_EQ(Perspective::IS_CLIENT, perspective_); | 473 DCHECK_EQ(Perspective::IS_CLIENT, perspective_); |
| 474 return server_supported_versions_; | 474 return server_supported_versions_; |
| 475 } | 475 } |
| 476 | 476 |
| 477 size_t NumFecGroups() const { return group_map_.size(); } | 477 size_t NumFecGroups() const { return group_map_.size(); } |
| 478 | 478 |
| 479 // Testing only. | 479 // Testing only. |
| 480 size_t NumQueuedPackets() const { return queued_packets_.size(); } | 480 size_t NumQueuedPackets() const { return queued_packets_.size(); } |
| 481 | 481 |
| 482 QuicEncryptedPacket* ReleaseConnectionClosePacket() { | 482 // Once called, any sent crypto packets to be saved as the |
| 483 return connection_close_packet_.release(); | 483 // termination packet, for use with stateless rejections. |
| 484 } | 484 void EnableSavingCryptoPackets(); |
| 485 | 485 |
| 486 // Returns true if the underlying UDP socket is writable, there is | 486 // Returns true if the underlying UDP socket is writable, there is |
| 487 // no queued data and the connection is not congestion-control | 487 // no queued data and the connection is not congestion-control |
| 488 // blocked. | 488 // blocked. |
| 489 bool CanWriteStreamData(); | 489 bool CanWriteStreamData(); |
| 490 | 490 |
| 491 // Returns true if the connection has queued packets or frames. | 491 // Returns true if the connection has queued packets or frames. |
| 492 bool HasQueuedData() const; | 492 bool HasQueuedData() const; |
| 493 | 493 |
| 494 // Sets the overall and idle state connection timeouts. | 494 // Sets the overall and idle state connection timeouts. |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 | 615 |
| 616 // Sends an MTU discovery packet of size |mtu_discovery_target_| and updates | 616 // Sends an MTU discovery packet of size |mtu_discovery_target_| and updates |
| 617 // the MTU discovery alarm. | 617 // the MTU discovery alarm. |
| 618 void DiscoverMtu(); | 618 void DiscoverMtu(); |
| 619 | 619 |
| 620 // Return the name of the cipher of the primary decrypter of the framer. | 620 // Return the name of the cipher of the primary decrypter of the framer. |
| 621 const char* cipher_name() const { return framer_.decrypter()->cipher_name(); } | 621 const char* cipher_name() const { return framer_.decrypter()->cipher_name(); } |
| 622 // Return the id of the cipher of the primary decrypter of the framer. | 622 // Return the id of the cipher of the primary decrypter of the framer. |
| 623 uint32 cipher_id() const { return framer_.decrypter()->cipher_id(); } | 623 uint32 cipher_id() const { return framer_.decrypter()->cipher_id(); } |
| 624 | 624 |
| 625 std::vector<QuicEncryptedPacket*>* termination_packets() { |
| 626 return termination_packets_.get(); |
| 627 } |
| 628 |
| 625 protected: | 629 protected: |
| 626 // Packets which have not been written to the wire. | 630 // Packets which have not been written to the wire. |
| 627 // Owns the QuicPacket* packet. | 631 // Owns the QuicPacket* packet. |
| 628 struct QueuedPacket { | 632 struct QueuedPacket { |
| 629 QueuedPacket(SerializedPacket packet, | 633 QueuedPacket(SerializedPacket packet, |
| 630 EncryptionLevel level); | 634 EncryptionLevel level); |
| 631 QueuedPacket(SerializedPacket packet, | 635 QueuedPacket(SerializedPacket packet, |
| 632 EncryptionLevel level, | 636 EncryptionLevel level, |
| 633 TransmissionType transmission_type, | 637 TransmissionType transmission_type, |
| 634 QuicPacketNumber original_packet_number); | 638 QuicPacketNumber original_packet_number); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 | 762 |
| 759 // Sets the MTU discovery alarm if necessary. | 763 // Sets the MTU discovery alarm if necessary. |
| 760 void MaybeSetMtuAlarm(); | 764 void MaybeSetMtuAlarm(); |
| 761 | 765 |
| 762 // On arrival of a new packet, checks to see if the socket addresses have | 766 // On arrival of a new packet, checks to see if the socket addresses have |
| 763 // changed since the last packet we saw on this connection. | 767 // changed since the last packet we saw on this connection. |
| 764 void CheckForAddressMigration(const IPEndPoint& self_address, | 768 void CheckForAddressMigration(const IPEndPoint& self_address, |
| 765 const IPEndPoint& peer_address); | 769 const IPEndPoint& peer_address); |
| 766 | 770 |
| 767 HasRetransmittableData IsRetransmittable(const QueuedPacket& packet); | 771 HasRetransmittableData IsRetransmittable(const QueuedPacket& packet); |
| 768 bool IsConnectionClose(const QueuedPacket& packet); | 772 bool IsTerminationPacket(const QueuedPacket& packet); |
| 769 | 773 |
| 770 // Set the size of the packet we are targeting while doing path MTU discovery. | 774 // Set the size of the packet we are targeting while doing path MTU discovery. |
| 771 void SetMtuDiscoveryTarget(QuicByteCount target); | 775 void SetMtuDiscoveryTarget(QuicByteCount target); |
| 772 | 776 |
| 773 // Validates the potential maximum packet size, and reduces it if it exceeds | 777 // Validates the potential maximum packet size, and reduces it if it exceeds |
| 774 // the largest supported by the protocol or the packet writer. | 778 // the largest supported by the protocol or the packet writer. |
| 775 QuicByteCount LimitMaxPacketSize(QuicByteCount suggested_max_packet_size); | 779 QuicByteCount LimitMaxPacketSize(QuicByteCount suggested_max_packet_size); |
| 776 | 780 |
| 777 QuicFramer framer_; | 781 QuicFramer framer_; |
| 778 QuicConnectionHelperInterface* helper_; // Not owned. | 782 QuicConnectionHelperInterface* helper_; // Not owned. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 | 832 |
| 829 // When the version negotiation packet could not be sent because the socket | 833 // When the version negotiation packet could not be sent because the socket |
| 830 // was not writable, this is set to true. | 834 // was not writable, this is set to true. |
| 831 bool pending_version_negotiation_packet_; | 835 bool pending_version_negotiation_packet_; |
| 832 | 836 |
| 833 // When packets could not be sent because the socket was not writable, | 837 // When packets could not be sent because the socket was not writable, |
| 834 // they are added to this list. All corresponding frames are in | 838 // they are added to this list. All corresponding frames are in |
| 835 // unacked_packets_ if they are to be retransmitted. | 839 // unacked_packets_ if they are to be retransmitted. |
| 836 QueuedPacketList queued_packets_; | 840 QueuedPacketList queued_packets_; |
| 837 | 841 |
| 838 // Contains the connection close packet if the connection has been closed. | 842 // If true, then crypto packets will be saved as termination packets. |
| 839 scoped_ptr<QuicEncryptedPacket> connection_close_packet_; | 843 bool save_crypto_packets_as_termination_packets_; |
| 844 |
| 845 // Contains the connection close packets if the connection has been closed. |
| 846 scoped_ptr<std::vector<QuicEncryptedPacket*>> termination_packets_; |
| 840 | 847 |
| 841 // When true, the connection does not send a close packet on timeout. | 848 // When true, the connection does not send a close packet on timeout. |
| 842 bool silent_close_enabled_; | 849 bool silent_close_enabled_; |
| 843 | 850 |
| 844 FecGroupMap group_map_; | 851 FecGroupMap group_map_; |
| 845 | 852 |
| 846 QuicReceivedPacketManager received_packet_manager_; | 853 QuicReceivedPacketManager received_packet_manager_; |
| 847 QuicSentEntropyManager sent_entropy_manager_; | 854 QuicSentEntropyManager sent_entropy_manager_; |
| 848 | 855 |
| 849 // Indicates whether an ack should be sent the next time we try to write. | 856 // Indicates whether an ack should be sent the next time we try to write. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 | 971 |
| 965 // Whether a GoAway has been received. | 972 // Whether a GoAway has been received. |
| 966 bool goaway_received_; | 973 bool goaway_received_; |
| 967 | 974 |
| 968 DISALLOW_COPY_AND_ASSIGN(QuicConnection); | 975 DISALLOW_COPY_AND_ASSIGN(QuicConnection); |
| 969 }; | 976 }; |
| 970 | 977 |
| 971 } // namespace net | 978 } // namespace net |
| 972 | 979 |
| 973 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 980 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
| OLD | NEW |