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 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 QuicAlarmFactory* alarm_factory() { return alarm_factory_; } | 668 QuicAlarmFactory* alarm_factory() { return alarm_factory_; } |
669 | 669 |
670 base::StringPiece GetCurrentPacket(); | 670 base::StringPiece GetCurrentPacket(); |
671 | 671 |
672 const QuicPacketGenerator& packet_generator() const { | 672 const QuicPacketGenerator& packet_generator() const { |
673 return packet_generator_; | 673 return packet_generator_; |
674 } | 674 } |
675 | 675 |
676 EncryptionLevel encryption_level() const { return encryption_level_; } | 676 EncryptionLevel encryption_level() const { return encryption_level_; } |
677 | 677 |
| 678 const IPEndPoint& last_packet_source_address() const { |
| 679 return last_packet_source_address_; |
| 680 } |
| 681 |
678 protected: | 682 protected: |
679 // Send a packet to the peer, and takes ownership of the packet if the packet | 683 // Send a packet to the peer, and takes ownership of the packet if the packet |
680 // cannot be written immediately. | 684 // cannot be written immediately. |
681 virtual void SendOrQueuePacket(SerializedPacket* packet); | 685 virtual void SendOrQueuePacket(SerializedPacket* packet); |
682 | 686 |
683 // Called after a packet is received from a new peer address and is | 687 // Called after a packet is received from a new peer address and is |
684 // decrypted. Starts validation of peer's address change. | 688 // decrypted. Starts validation of peer's address change. |
685 virtual void StartPeerMigration(PeerAddressChangeType peer_migration_type); | 689 virtual void StartPeerMigration(PeerAddressChangeType peer_migration_type); |
686 | 690 |
687 // Called when a peer migration is validated. | 691 // Called when a peer migration is validated. |
688 virtual void OnPeerMigrationValidated(); | 692 virtual void OnPeerMigrationValidated(); |
689 | 693 |
690 // Selects and updates the version of the protocol being used by selecting a | 694 // Selects and updates the version of the protocol being used by selecting a |
691 // version from |available_versions| which is also supported. Returns true if | 695 // version from |available_versions| which is also supported. Returns true if |
692 // such a version exists, false otherwise. | 696 // such a version exists, false otherwise. |
693 bool SelectMutualVersion(const QuicVersionVector& available_versions); | 697 bool SelectMutualVersion(const QuicVersionVector& available_versions); |
694 | 698 |
695 const IPEndPoint& last_packet_source_address() const { | |
696 return last_packet_source_address_; | |
697 } | |
698 | |
699 // Returns the current per-packet options for the connection. | 699 // Returns the current per-packet options for the connection. |
700 PerPacketOptions* per_packet_options() { return per_packet_options_; } | 700 PerPacketOptions* per_packet_options() { return per_packet_options_; } |
701 // Sets the current per-packet options for the connection. The QuicConnection | 701 // Sets the current per-packet options for the connection. The QuicConnection |
702 // does not take ownership of |options|; |options| must live for as long as | 702 // does not take ownership of |options|; |options| must live for as long as |
703 // the QuicConnection is in use. | 703 // the QuicConnection is in use. |
704 void set_per_packet_options(PerPacketOptions* options) { | 704 void set_per_packet_options(PerPacketOptions* options) { |
705 per_packet_options_ = options; | 705 per_packet_options_ = options; |
706 } | 706 } |
707 | 707 |
708 // If |defer| is true, configures the connection to defer sending packets in | 708 // If |defer| is true, configures the connection to defer sending packets in |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 // other paths. | 831 // other paths. |
832 // TODO(fayang): complete OnPathClosed once QuicMultipathSentPacketManager and | 832 // TODO(fayang): complete OnPathClosed once QuicMultipathSentPacketManager and |
833 // QuicMultipathReceivedPacketManager are landed in QuicConnection. | 833 // QuicMultipathReceivedPacketManager are landed in QuicConnection. |
834 void OnPathClosed(QuicPathId path_id); | 834 void OnPathClosed(QuicPathId path_id); |
835 | 835 |
836 // Do any work which logically would be done in OnPacket but can not be | 836 // Do any work which logically would be done in OnPacket but can not be |
837 // safely done until the packet is validated. Returns true if packet can be | 837 // safely done until the packet is validated. Returns true if packet can be |
838 // handled, false otherwise. | 838 // handled, false otherwise. |
839 bool ProcessValidatedPacket(const QuicPacketHeader& header); | 839 bool ProcessValidatedPacket(const QuicPacketHeader& header); |
840 | 840 |
| 841 // Consider receiving crypto frame on non crypto stream as memory corruption. |
| 842 bool MaybeConsiderAsMemoryCorruption(const QuicStreamFrame& frame); |
| 843 |
841 QuicFramer framer_; | 844 QuicFramer framer_; |
842 QuicConnectionHelperInterface* helper_; // Not owned. | 845 QuicConnectionHelperInterface* helper_; // Not owned. |
843 QuicAlarmFactory* alarm_factory_; // Not owned. | 846 QuicAlarmFactory* alarm_factory_; // Not owned. |
844 PerPacketOptions* per_packet_options_; // Not owned. | 847 PerPacketOptions* per_packet_options_; // Not owned. |
845 QuicPacketWriter* writer_; // Owned or not depending on |owns_writer_|. | 848 QuicPacketWriter* writer_; // Owned or not depending on |owns_writer_|. |
846 bool owns_writer_; | 849 bool owns_writer_; |
847 // Encryption level for new packets. Should only be changed via | 850 // Encryption level for new packets. Should only be changed via |
848 // SetDefaultEncryptionLevel(). | 851 // SetDefaultEncryptionLevel(). |
849 EncryptionLevel encryption_level_; | 852 EncryptionLevel encryption_level_; |
850 bool has_forward_secure_encrypter_; | 853 bool has_forward_secure_encrypter_; |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 | 1061 |
1059 // If true, multipath is enabled for this connection. | 1062 // If true, multipath is enabled for this connection. |
1060 bool multipath_enabled_; | 1063 bool multipath_enabled_; |
1061 | 1064 |
1062 DISALLOW_COPY_AND_ASSIGN(QuicConnection); | 1065 DISALLOW_COPY_AND_ASSIGN(QuicConnection); |
1063 }; | 1066 }; |
1064 | 1067 |
1065 } // namespace net | 1068 } // namespace net |
1066 | 1069 |
1067 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 1070 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
OLD | NEW |