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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 CloseConnection(QUIC_INVALID_VERSION_NEGOTIATION_PACKET, false); | 402 CloseConnection(QUIC_INVALID_VERSION_NEGOTIATION_PACKET, false); |
403 return; | 403 return; |
404 } | 404 } |
405 | 405 |
406 if (!SelectMutualVersion(packet.versions)) { | 406 if (!SelectMutualVersion(packet.versions)) { |
407 SendConnectionCloseWithDetails(QUIC_INVALID_VERSION, | 407 SendConnectionCloseWithDetails(QUIC_INVALID_VERSION, |
408 "no common version found"); | 408 "no common version found"); |
409 return; | 409 return; |
410 } | 410 } |
411 | 411 |
412 DVLOG(1) << ENDPOINT << "negotiating version " << version(); | 412 DVLOG(1) << ENDPOINT |
| 413 << "Negotiated version: " << QuicVersionToString(version()); |
413 server_supported_versions_ = packet.versions; | 414 server_supported_versions_ = packet.versions; |
414 version_negotiation_state_ = NEGOTIATION_IN_PROGRESS; | 415 version_negotiation_state_ = NEGOTIATION_IN_PROGRESS; |
415 RetransmitUnackedPackets(ALL_PACKETS); | 416 RetransmitUnackedPackets(ALL_PACKETS); |
416 } | 417 } |
417 | 418 |
418 void QuicConnection::OnRevivedPacket() { | 419 void QuicConnection::OnRevivedPacket() { |
419 } | 420 } |
420 | 421 |
421 bool QuicConnection::OnUnauthenticatedPublicHeader( | 422 bool QuicConnection::OnUnauthenticatedPublicHeader( |
422 const QuicPacketPublicHeader& header) { | 423 const QuicPacketPublicHeader& header) { |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 } | 963 } |
963 } | 964 } |
964 | 965 |
965 void QuicConnection::SendVersionNegotiationPacket() { | 966 void QuicConnection::SendVersionNegotiationPacket() { |
966 // TODO(alyssar): implement zero server state negotiation. | 967 // TODO(alyssar): implement zero server state negotiation. |
967 pending_version_negotiation_packet_ = true; | 968 pending_version_negotiation_packet_ = true; |
968 if (writer_->IsWriteBlocked()) { | 969 if (writer_->IsWriteBlocked()) { |
969 visitor_->OnWriteBlocked(); | 970 visitor_->OnWriteBlocked(); |
970 return; | 971 return; |
971 } | 972 } |
| 973 DVLOG(1) << ENDPOINT << "Sending version negotiation packet: {" |
| 974 << QuicVersionVectorToString(framer_.supported_versions()) << "}"; |
972 scoped_ptr<QuicEncryptedPacket> version_packet( | 975 scoped_ptr<QuicEncryptedPacket> version_packet( |
973 packet_generator_.SerializeVersionNegotiationPacket( | 976 packet_generator_.SerializeVersionNegotiationPacket( |
974 framer_.supported_versions())); | 977 framer_.supported_versions())); |
975 WriteResult result = writer_->WritePacket( | 978 WriteResult result = writer_->WritePacket( |
976 version_packet->data(), version_packet->length(), | 979 version_packet->data(), version_packet->length(), |
977 self_address().address(), peer_address()); | 980 self_address().address(), peer_address()); |
978 | 981 |
979 if (result.status == WRITE_STATUS_ERROR) { | 982 if (result.status == WRITE_STATUS_ERROR) { |
980 // We can't send an error as the socket is presumably borked. | 983 // We can't send an error as the socket is presumably borked. |
981 CloseConnection(QUIC_PACKET_WRITE_ERROR, false); | 984 CloseConnection(QUIC_PACKET_WRITE_ERROR, false); |
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1999 // If we changed the generator's batch state, restore original batch state. | 2002 // If we changed the generator's batch state, restore original batch state. |
2000 if (!already_in_batch_mode_) { | 2003 if (!already_in_batch_mode_) { |
2001 DVLOG(1) << "Leaving Batch Mode."; | 2004 DVLOG(1) << "Leaving Batch Mode."; |
2002 connection_->packet_generator_.FinishBatchOperations(); | 2005 connection_->packet_generator_.FinishBatchOperations(); |
2003 } | 2006 } |
2004 DCHECK_EQ(already_in_batch_mode_, | 2007 DCHECK_EQ(already_in_batch_mode_, |
2005 connection_->packet_generator_.InBatchMode()); | 2008 connection_->packet_generator_.InBatchMode()); |
2006 } | 2009 } |
2007 | 2010 |
2008 } // namespace net | 2011 } // namespace net |
OLD | NEW |