| 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/core/quic_connection.h" | 5 #include "net/quic/core/quic_connection.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <sys/types.h> | 8 #include <sys/types.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 DLOG(WARNING) << error_details; | 529 DLOG(WARNING) << error_details; |
| 530 TearDownLocalConnectionState(QUIC_INVALID_VERSION_NEGOTIATION_PACKET, | 530 TearDownLocalConnectionState(QUIC_INVALID_VERSION_NEGOTIATION_PACKET, |
| 531 error_details, | 531 error_details, |
| 532 ConnectionCloseSource::FROM_SELF); | 532 ConnectionCloseSource::FROM_SELF); |
| 533 return; | 533 return; |
| 534 } | 534 } |
| 535 | 535 |
| 536 if (!SelectMutualVersion(packet.versions)) { | 536 if (!SelectMutualVersion(packet.versions)) { |
| 537 CloseConnection( | 537 CloseConnection( |
| 538 QUIC_INVALID_VERSION, | 538 QUIC_INVALID_VERSION, |
| 539 "No common version found. Supported versions: {" + | 539 QuicStrCat("No common version found. Supported versions: {", |
| 540 QuicVersionVectorToString(framer_.supported_versions()) + | 540 QuicVersionVectorToString(framer_.supported_versions()), |
| 541 "}, peer supported versions: {" + | 541 "}, peer supported versions: {", |
| 542 QuicVersionVectorToString(packet.versions) + "}", | 542 QuicVersionVectorToString(packet.versions), "}"), |
| 543 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); | 543 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
| 544 return; | 544 return; |
| 545 } | 545 } |
| 546 | 546 |
| 547 DVLOG(1) << ENDPOINT | 547 DVLOG(1) << ENDPOINT |
| 548 << "Negotiated version: " << QuicVersionToString(version()); | 548 << "Negotiated version: " << QuicVersionToString(version()); |
| 549 server_supported_versions_ = packet.versions; | 549 server_supported_versions_ = packet.versions; |
| 550 version_negotiation_state_ = NEGOTIATION_IN_PROGRESS; | 550 version_negotiation_state_ = NEGOTIATION_IN_PROGRESS; |
| 551 RetransmitUnackedPackets(ALL_UNACKED_RETRANSMISSION); | 551 RetransmitUnackedPackets(ALL_UNACKED_RETRANSMISSION); |
| 552 } | 552 } |
| (...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); | 1366 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
| 1367 return false; | 1367 return false; |
| 1368 } | 1368 } |
| 1369 | 1369 |
| 1370 if (version_negotiation_state_ != NEGOTIATED_VERSION) { | 1370 if (version_negotiation_state_ != NEGOTIATED_VERSION) { |
| 1371 if (perspective_ == Perspective::IS_SERVER) { | 1371 if (perspective_ == Perspective::IS_SERVER) { |
| 1372 if (!header.public_header.version_flag) { | 1372 if (!header.public_header.version_flag) { |
| 1373 // Packets should have the version flag till version negotiation is | 1373 // Packets should have the version flag till version negotiation is |
| 1374 // done. | 1374 // done. |
| 1375 string error_details = | 1375 string error_details = |
| 1376 StringPrintf("%s Packet %" PRIu64 | 1376 QuicStrCat(ENDPOINT, "Packet ", header.packet_number, |
| 1377 " without version flag before version negotiated.", | 1377 " without version flag before version negotiated."); |
| 1378 ENDPOINT, header.packet_number); | |
| 1379 DLOG(WARNING) << error_details; | 1378 DLOG(WARNING) << error_details; |
| 1380 CloseConnection(QUIC_INVALID_VERSION, error_details, | 1379 CloseConnection(QUIC_INVALID_VERSION, error_details, |
| 1381 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); | 1380 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
| 1382 return false; | 1381 return false; |
| 1383 } else { | 1382 } else { |
| 1384 DCHECK_EQ(1u, header.public_header.versions.size()); | 1383 DCHECK_EQ(1u, header.public_header.versions.size()); |
| 1385 DCHECK_EQ(header.public_header.versions[0], version()); | 1384 DCHECK_EQ(header.public_header.versions[0], version()); |
| 1386 version_negotiation_state_ = NEGOTIATED_VERSION; | 1385 version_negotiation_state_ = NEGOTIATED_VERSION; |
| 1387 visitor_->OnSuccessfulVersionNegotiation(version()); | 1386 visitor_->OnSuccessfulVersionNegotiation(version()); |
| 1388 if (debug_visitor_ != nullptr) { | 1387 if (debug_visitor_ != nullptr) { |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1687 return false; | 1686 return false; |
| 1688 } | 1687 } |
| 1689 | 1688 |
| 1690 void QuicConnection::OnWriteError(int error_code) { | 1689 void QuicConnection::OnWriteError(int error_code) { |
| 1691 if (write_error_occured_) { | 1690 if (write_error_occured_) { |
| 1692 // A write error already occurred. The connection is being closed. | 1691 // A write error already occurred. The connection is being closed. |
| 1693 return; | 1692 return; |
| 1694 } | 1693 } |
| 1695 write_error_occured_ = true; | 1694 write_error_occured_ = true; |
| 1696 | 1695 |
| 1697 const string error_details = "Write failed with error: " + | 1696 const string error_details = QuicStrCat( |
| 1698 base::IntToString(error_code) + " (" + | 1697 "Write failed with error: ", error_code, " (", strerror(error_code), ")"); |
| 1699 ErrorToString(error_code) + ")"; | |
| 1700 DVLOG(1) << ENDPOINT << error_details; | 1698 DVLOG(1) << ENDPOINT << error_details; |
| 1701 // We can't send an error as the socket is presumably borked. | 1699 // We can't send an error as the socket is presumably borked. |
| 1702 switch (error_code) { | 1700 switch (error_code) { |
| 1703 case kMessageTooBigErrorCode: | 1701 case kMessageTooBigErrorCode: |
| 1704 CloseConnection( | 1702 CloseConnection( |
| 1705 QUIC_PACKET_WRITE_ERROR, error_details, | 1703 QUIC_PACKET_WRITE_ERROR, error_details, |
| 1706 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET_WITH_NO_ACK); | 1704 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET_WITH_NO_ACK); |
| 1707 break; | 1705 break; |
| 1708 default: | 1706 default: |
| 1709 // We can't send an error as the socket is presumably borked. | 1707 // We can't send an error as the socket is presumably borked. |
| (...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2458 | 2456 |
| 2459 void QuicConnection::CheckIfApplicationLimited() { | 2457 void QuicConnection::CheckIfApplicationLimited() { |
| 2460 if (queued_packets_.empty() && | 2458 if (queued_packets_.empty() && |
| 2461 !sent_packet_manager_->HasPendingRetransmissions() && | 2459 !sent_packet_manager_->HasPendingRetransmissions() && |
| 2462 !visitor_->WillingAndAbleToWrite()) { | 2460 !visitor_->WillingAndAbleToWrite()) { |
| 2463 sent_packet_manager_->OnApplicationLimited(); | 2461 sent_packet_manager_->OnApplicationLimited(); |
| 2464 } | 2462 } |
| 2465 } | 2463 } |
| 2466 | 2464 |
| 2467 } // namespace net | 2465 } // namespace net |
| OLD | NEW |