| 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 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 | 656 |
| 657 std::vector<QuicEncryptedPacket*>* termination_packets() { | 657 std::vector<QuicEncryptedPacket*>* termination_packets() { |
| 658 return termination_packets_.get(); | 658 return termination_packets_.get(); |
| 659 } | 659 } |
| 660 | 660 |
| 661 bool ack_frame_updated() const; | 661 bool ack_frame_updated() const; |
| 662 | 662 |
| 663 QuicConnectionHelperInterface* helper() { return helper_; } | 663 QuicConnectionHelperInterface* helper() { return helper_; } |
| 664 | 664 |
| 665 protected: | 665 protected: |
| 666 // Do any work which logically would be done in OnPacket but can not be | |
| 667 // safely done until the packet is validated. Returns true if the packet | |
| 668 // can be handled, false otherwise. Also migrates the connection if the packet | |
| 669 // can be handled and peer address changes. | |
| 670 virtual bool ProcessValidatedPacket(const QuicPacketHeader& header); | |
| 671 | |
| 672 // Send a packet to the peer, and takes ownership of the packet if the packet | 666 // Send a packet to the peer, and takes ownership of the packet if the packet |
| 673 // cannot be written immediately. | 667 // cannot be written immediately. |
| 674 virtual void SendOrQueuePacket(SerializedPacket* packet); | 668 virtual void SendOrQueuePacket(SerializedPacket* packet); |
| 675 | 669 |
| 676 // On peer address changes, determine and return the change type. | 670 // On peer address changes, determine and return peer address change type. |
| 677 virtual PeerAddressChangeType DeterminePeerAddressChangeType(); | 671 PeerAddressChangeType DeterminePeerAddressChangeType(); |
| 672 |
| 673 // Migrate the connection if peer address changes. This function should only |
| 674 // be called after the packet is validated. |
| 675 virtual void MaybeMigrateConnectionToNewPeerAddress(); |
| 678 | 676 |
| 679 // Selects and updates the version of the protocol being used by selecting a | 677 // Selects and updates the version of the protocol being used by selecting a |
| 680 // version from |available_versions| which is also supported. Returns true if | 678 // version from |available_versions| which is also supported. Returns true if |
| 681 // such a version exists, false otherwise. | 679 // such a version exists, false otherwise. |
| 682 bool SelectMutualVersion(const QuicVersionVector& available_versions); | 680 bool SelectMutualVersion(const QuicVersionVector& available_versions); |
| 683 | 681 |
| 684 bool peer_ip_changed() const { return peer_ip_changed_; } | 682 bool peer_ip_changed() const { return peer_ip_changed_; } |
| 685 | 683 |
| 686 bool peer_port_changed() const { return peer_port_changed_; } | 684 bool peer_port_changed() const { return peer_port_changed_; } |
| 687 | 685 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 | 812 |
| 815 // Called when |path_id| is considered as closed because either a PATH_CLOSE | 813 // Called when |path_id| is considered as closed because either a PATH_CLOSE |
| 816 // frame is sent or received. Stops receiving packets on closed path. Drops | 814 // frame is sent or received. Stops receiving packets on closed path. Drops |
| 817 // receive side of a closed path, and packets with retransmittable frames on a | 815 // receive side of a closed path, and packets with retransmittable frames on a |
| 818 // closed path are marked as retransmissions which will be transmitted on | 816 // closed path are marked as retransmissions which will be transmitted on |
| 819 // other paths. | 817 // other paths. |
| 820 // TODO(fayang): complete OnPathClosed once QuicMultipathSentPacketManager and | 818 // TODO(fayang): complete OnPathClosed once QuicMultipathSentPacketManager and |
| 821 // QuicMultipathReceivedPacketManager are landed in QuicConnection. | 819 // QuicMultipathReceivedPacketManager are landed in QuicConnection. |
| 822 void OnPathClosed(QuicPathId path_id); | 820 void OnPathClosed(QuicPathId path_id); |
| 823 | 821 |
| 822 // Do any work which logically would be done in OnPacket but can not be |
| 823 // safely done until the packet is validated. Returns true if packet can be |
| 824 // handled, false otherwise. |
| 825 bool ProcessValidatedPacket(const QuicPacketHeader& header); |
| 826 |
| 824 QuicFramer framer_; | 827 QuicFramer framer_; |
| 825 QuicConnectionHelperInterface* helper_; // Not owned. | 828 QuicConnectionHelperInterface* helper_; // Not owned. |
| 826 PerPacketOptions* per_packet_options_; // Not owned. | 829 PerPacketOptions* per_packet_options_; // Not owned. |
| 827 QuicPacketWriter* writer_; // Owned or not depending on |owns_writer_|. | 830 QuicPacketWriter* writer_; // Owned or not depending on |owns_writer_|. |
| 828 bool owns_writer_; | 831 bool owns_writer_; |
| 829 // Encryption level for new packets. Should only be changed via | 832 // Encryption level for new packets. Should only be changed via |
| 830 // SetDefaultEncryptionLevel(). | 833 // SetDefaultEncryptionLevel(). |
| 831 EncryptionLevel encryption_level_; | 834 EncryptionLevel encryption_level_; |
| 832 bool has_forward_secure_encrypter_; | 835 bool has_forward_secure_encrypter_; |
| 833 // The packet number of the first packet which will be encrypted with the | 836 // The packet number of the first packet which will be encrypted with the |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 bool peer_port_changed_; | 993 bool peer_port_changed_; |
| 991 | 994 |
| 992 // Set to true if the UDP packet headers are addressed to a different IP. | 995 // Set to true if the UDP packet headers are addressed to a different IP. |
| 993 // We do not support connection migration when the self IP changed. | 996 // We do not support connection migration when the self IP changed. |
| 994 bool self_ip_changed_; | 997 bool self_ip_changed_; |
| 995 | 998 |
| 996 // Set to true if the UDP packet headers are addressed to a different port. | 999 // Set to true if the UDP packet headers are addressed to a different port. |
| 997 // We do not support connection migration when the self port changed. | 1000 // We do not support connection migration when the self port changed. |
| 998 bool self_port_changed_; | 1001 bool self_port_changed_; |
| 999 | 1002 |
| 1003 // Destination address of the last received packet. |
| 1004 IPEndPoint last_packet_destination_address_; |
| 1005 |
| 1006 // Source address of the last received packet. |
| 1007 IPEndPoint last_packet_source_address_; |
| 1008 |
| 1000 // Set to false if the connection should not send truncated connection IDs to | 1009 // Set to false if the connection should not send truncated connection IDs to |
| 1001 // the peer, even if the peer supports it. | 1010 // the peer, even if the peer supports it. |
| 1002 bool can_truncate_connection_ids_; | 1011 bool can_truncate_connection_ids_; |
| 1003 | 1012 |
| 1004 // If non-empty this contains the set of versions received in a | 1013 // If non-empty this contains the set of versions received in a |
| 1005 // version negotiation packet. | 1014 // version negotiation packet. |
| 1006 QuicVersionVector server_supported_versions_; | 1015 QuicVersionVector server_supported_versions_; |
| 1007 | 1016 |
| 1008 // The size of the packet we are targeting while doing path MTU discovery. | 1017 // The size of the packet we are targeting while doing path MTU discovery. |
| 1009 QuicByteCount mtu_discovery_target_; | 1018 QuicByteCount mtu_discovery_target_; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1029 | 1038 |
| 1030 // If true, multipath is enabled for this connection. | 1039 // If true, multipath is enabled for this connection. |
| 1031 bool multipath_enabled_; | 1040 bool multipath_enabled_; |
| 1032 | 1041 |
| 1033 DISALLOW_COPY_AND_ASSIGN(QuicConnection); | 1042 DISALLOW_COPY_AND_ASSIGN(QuicConnection); |
| 1034 }; | 1043 }; |
| 1035 | 1044 |
| 1036 } // namespace net | 1045 } // namespace net |
| 1037 | 1046 |
| 1038 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 1047 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
| OLD | NEW |