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 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1223 listener); | 1223 listener); |
1224 } | 1224 } |
1225 return packet_generator_.ConsumeData(id, iov, offset, fin, listener); | 1225 return packet_generator_.ConsumeData(id, iov, offset, fin, listener); |
1226 } | 1226 } |
1227 | 1227 |
1228 void QuicConnection::SendRstStream(QuicStreamId id, | 1228 void QuicConnection::SendRstStream(QuicStreamId id, |
1229 QuicRstStreamErrorCode error, | 1229 QuicRstStreamErrorCode error, |
1230 QuicStreamOffset bytes_written) { | 1230 QuicStreamOffset bytes_written) { |
1231 // Opportunistically bundle an ack with this outgoing packet. | 1231 // Opportunistically bundle an ack with this outgoing packet. |
1232 ScopedPacketBundler ack_bundler(this, SEND_ACK_IF_PENDING); | 1232 ScopedPacketBundler ack_bundler(this, SEND_ACK_IF_PENDING); |
1233 packet_generator_.AddControlFrame(QuicFrame(new QuicRstStreamFrame( | 1233 packet_generator_.AddControlFrame( |
1234 id, AdjustErrorForVersion(error, version()), bytes_written))); | 1234 QuicFrame(new QuicRstStreamFrame(id, error, bytes_written))); |
1235 | 1235 |
1236 if (error == QUIC_STREAM_NO_ERROR) { | 1236 if (error == QUIC_STREAM_NO_ERROR) { |
1237 // All data for streams which are reset with QUIC_STREAM_NO_ERROR must | 1237 // All data for streams which are reset with QUIC_STREAM_NO_ERROR must |
1238 // be received by the peer. | 1238 // be received by the peer. |
1239 return; | 1239 return; |
1240 } | 1240 } |
1241 | 1241 |
1242 sent_packet_manager_->CancelRetransmissionsForStream(id); | 1242 sent_packet_manager_->CancelRetransmissionsForStream(id); |
1243 // Remove all queued packets which only contain data for the reset stream. | 1243 // Remove all queued packets which only contain data for the reset stream. |
1244 QueuedPacketList::iterator packet_iterator = queued_packets_.begin(); | 1244 QueuedPacketList::iterator packet_iterator = queued_packets_.begin(); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1414 ScopedPacketBundler bundler(this, SEND_ACK_IF_QUEUED); | 1414 ScopedPacketBundler bundler(this, SEND_ACK_IF_QUEUED); |
1415 OnCanWrite(); | 1415 OnCanWrite(); |
1416 } | 1416 } |
1417 } | 1417 } |
1418 | 1418 |
1419 bool QuicConnection::ProcessValidatedPacket(const QuicPacketHeader& header) { | 1419 bool QuicConnection::ProcessValidatedPacket(const QuicPacketHeader& header) { |
1420 if (perspective_ == Perspective::IS_SERVER && | 1420 if (perspective_ == Perspective::IS_SERVER && |
1421 IsInitializedIPEndPoint(self_address_) && | 1421 IsInitializedIPEndPoint(self_address_) && |
1422 IsInitializedIPEndPoint(last_packet_destination_address_) && | 1422 IsInitializedIPEndPoint(last_packet_destination_address_) && |
1423 (!(self_address_ == last_packet_destination_address_))) { | 1423 (!(self_address_ == last_packet_destination_address_))) { |
1424 if (!FLAGS_quic_allow_server_address_change_for_mapped_ipv4) { | |
1425 CloseConnection(QUIC_ERROR_MIGRATING_ADDRESS, | |
1426 "Self address migration is not supported at the server.", | |
1427 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); | |
1428 return false; | |
1429 } | |
1430 // Allow change between pure IPv4 and equivalent mapped IPv4 address. | 1424 // Allow change between pure IPv4 and equivalent mapped IPv4 address. |
1431 IPAddress self_ip = self_address_.address(); | 1425 IPAddress self_ip = self_address_.address(); |
1432 if (self_ip.IsIPv4MappedIPv6()) { | 1426 if (self_ip.IsIPv4MappedIPv6()) { |
1433 self_ip = ConvertIPv4MappedIPv6ToIPv4(self_ip); | 1427 self_ip = ConvertIPv4MappedIPv6ToIPv4(self_ip); |
1434 } | 1428 } |
1435 IPAddress last_packet_destination_ip = | 1429 IPAddress last_packet_destination_ip = |
1436 last_packet_destination_address_.address(); | 1430 last_packet_destination_address_.address(); |
1437 if (last_packet_destination_ip.IsIPv4MappedIPv6()) { | 1431 if (last_packet_destination_ip.IsIPv4MappedIPv6()) { |
1438 last_packet_destination_ip = | 1432 last_packet_destination_ip = |
1439 ConvertIPv4MappedIPv6ToIPv4(last_packet_destination_ip); | 1433 ConvertIPv4MappedIPv6ToIPv4(last_packet_destination_ip); |
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2590 | 2584 |
2591 void QuicConnection::CheckIfApplicationLimited() { | 2585 void QuicConnection::CheckIfApplicationLimited() { |
2592 if (queued_packets_.empty() && | 2586 if (queued_packets_.empty() && |
2593 !sent_packet_manager_->HasPendingRetransmissions() && | 2587 !sent_packet_manager_->HasPendingRetransmissions() && |
2594 !visitor_->WillingAndAbleToWrite()) { | 2588 !visitor_->WillingAndAbleToWrite()) { |
2595 sent_packet_manager_->OnApplicationLimited(); | 2589 sent_packet_manager_->OnApplicationLimited(); |
2596 } | 2590 } |
2597 } | 2591 } |
2598 | 2592 |
2599 } // namespace net | 2593 } // namespace net |
OLD | NEW |