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 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 } | 1172 } |
1173 } | 1173 } |
1174 | 1174 |
1175 void QuicConnection::WriteIfNotBlocked() { | 1175 void QuicConnection::WriteIfNotBlocked() { |
1176 if (!writer_->IsWriteBlocked()) { | 1176 if (!writer_->IsWriteBlocked()) { |
1177 OnCanWrite(); | 1177 OnCanWrite(); |
1178 } | 1178 } |
1179 } | 1179 } |
1180 | 1180 |
1181 bool QuicConnection::ProcessValidatedPacket() { | 1181 bool QuicConnection::ProcessValidatedPacket() { |
1182 if ((!FLAGS_quic_allow_port_migration && peer_port_changed_) || | 1182 if (peer_ip_changed_ || self_ip_changed_ || self_port_changed_) { |
1183 peer_ip_changed_ || self_ip_changed_ || self_port_changed_) { | |
1184 SendConnectionCloseWithDetails( | 1183 SendConnectionCloseWithDetails( |
1185 QUIC_ERROR_MIGRATING_ADDRESS, | 1184 QUIC_ERROR_MIGRATING_ADDRESS, |
1186 "Neither IP address migration, nor self port migration are supported."); | 1185 "Neither IP address migration, nor self port migration are supported."); |
1187 return false; | 1186 return false; |
1188 } | 1187 } |
1189 | 1188 |
1190 // Port migration is supported, do it now if port has changed. | 1189 // Peer port migration is supported, do it now if port has changed. |
1191 if (FLAGS_quic_allow_port_migration && | 1190 if (peer_port_changed_) { |
1192 peer_port_changed_) { | |
1193 DVLOG(1) << ENDPOINT << "Peer's port changed from " | 1191 DVLOG(1) << ENDPOINT << "Peer's port changed from " |
1194 << peer_address_.port() << " to " << migrating_peer_port_ | 1192 << peer_address_.port() << " to " << migrating_peer_port_ |
1195 << ", migrating connection."; | 1193 << ", migrating connection."; |
1196 peer_address_ = IPEndPoint(peer_address_.address(), migrating_peer_port_); | 1194 peer_address_ = IPEndPoint(peer_address_.address(), migrating_peer_port_); |
1197 } | 1195 } |
1198 | 1196 |
1199 time_of_last_received_packet_ = clock_->Now(); | 1197 time_of_last_received_packet_ = clock_->Now(); |
1200 DVLOG(1) << ENDPOINT << "time of last received packet: " | 1198 DVLOG(1) << ENDPOINT << "time of last received packet: " |
1201 << time_of_last_received_packet_.ToDebuggingValue(); | 1199 << time_of_last_received_packet_.ToDebuggingValue(); |
1202 | 1200 |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1535 set_encryption_level(encryption_level_); | 1533 set_encryption_level(encryption_level_); |
1536 } | 1534 } |
1537 sent_packet_manager_.OnSerializedPacket(serialized_packet); | 1535 sent_packet_manager_.OnSerializedPacket(serialized_packet); |
1538 // The TransmissionType is NOT_RETRANSMISSION because all retransmissions | 1536 // The TransmissionType is NOT_RETRANSMISSION because all retransmissions |
1539 // serialize packets and invoke SendOrQueuePacket directly. | 1537 // serialize packets and invoke SendOrQueuePacket directly. |
1540 return SendOrQueuePacket(encryption_level_, | 1538 return SendOrQueuePacket(encryption_level_, |
1541 serialized_packet, | 1539 serialized_packet, |
1542 NOT_RETRANSMISSION); | 1540 NOT_RETRANSMISSION); |
1543 } | 1541 } |
1544 | 1542 |
| 1543 void QuicConnection::OnHandshakeComplete() { |
| 1544 sent_packet_manager_.SetHandshakeConfirmed(); |
| 1545 } |
| 1546 |
1545 bool QuicConnection::SendOrQueuePacket(EncryptionLevel level, | 1547 bool QuicConnection::SendOrQueuePacket(EncryptionLevel level, |
1546 const SerializedPacket& packet, | 1548 const SerializedPacket& packet, |
1547 TransmissionType transmission_type) { | 1549 TransmissionType transmission_type) { |
1548 if (packet.packet == NULL) { | 1550 if (packet.packet == NULL) { |
1549 LOG(DFATAL) << "NULL packet passed in to SendOrQueuePacket"; | 1551 LOG(DFATAL) << "NULL packet passed in to SendOrQueuePacket"; |
1550 return true; | 1552 return true; |
1551 } | 1553 } |
1552 | 1554 |
1553 sent_entropy_manager_.RecordPacketEntropyHash(packet.sequence_number, | 1555 sent_entropy_manager_.RecordPacketEntropyHash(packet.sequence_number, |
1554 packet.entropy_hash); | 1556 packet.entropy_hash); |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1789 packet_generator_.FlushAllQueuedFrames(); | 1791 packet_generator_.FlushAllQueuedFrames(); |
1790 } | 1792 } |
1791 | 1793 |
1792 void QuicConnection::CloseConnection(QuicErrorCode error, bool from_peer) { | 1794 void QuicConnection::CloseConnection(QuicErrorCode error, bool from_peer) { |
1793 if (!connected_) { | 1795 if (!connected_) { |
1794 DLOG(DFATAL) << "Error: attempt to close an already closed connection" | 1796 DLOG(DFATAL) << "Error: attempt to close an already closed connection" |
1795 << base::debug::StackTrace().ToString(); | 1797 << base::debug::StackTrace().ToString(); |
1796 return; | 1798 return; |
1797 } | 1799 } |
1798 connected_ = false; | 1800 connected_ = false; |
| 1801 if (debug_visitor_.get() != NULL) { |
| 1802 debug_visitor_->OnConnectionClosed(error, from_peer); |
| 1803 } |
1799 visitor_->OnConnectionClosed(error, from_peer); | 1804 visitor_->OnConnectionClosed(error, from_peer); |
1800 // Cancel the alarms so they don't trigger any action now that the | 1805 // Cancel the alarms so they don't trigger any action now that the |
1801 // connection is closed. | 1806 // connection is closed. |
1802 ack_alarm_->Cancel(); | 1807 ack_alarm_->Cancel(); |
1803 resume_writes_alarm_->Cancel(); | 1808 resume_writes_alarm_->Cancel(); |
1804 retransmission_alarm_->Cancel(); | 1809 retransmission_alarm_->Cancel(); |
1805 send_alarm_->Cancel(); | 1810 send_alarm_->Cancel(); |
1806 timeout_alarm_->Cancel(); | 1811 timeout_alarm_->Cancel(); |
1807 } | 1812 } |
1808 | 1813 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1983 // If we changed the generator's batch state, restore original batch state. | 1988 // If we changed the generator's batch state, restore original batch state. |
1984 if (!already_in_batch_mode_) { | 1989 if (!already_in_batch_mode_) { |
1985 DVLOG(1) << "Leaving Batch Mode."; | 1990 DVLOG(1) << "Leaving Batch Mode."; |
1986 connection_->packet_generator_.FinishBatchOperations(); | 1991 connection_->packet_generator_.FinishBatchOperations(); |
1987 } | 1992 } |
1988 DCHECK_EQ(already_in_batch_mode_, | 1993 DCHECK_EQ(already_in_batch_mode_, |
1989 connection_->packet_generator_.InBatchMode()); | 1994 connection_->packet_generator_.InBatchMode()); |
1990 } | 1995 } |
1991 | 1996 |
1992 } // namespace net | 1997 } // namespace net |
OLD | NEW |