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 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 bool QuicConnection::ProcessValidatedPacket(const QuicPacketHeader& header) { | 1397 bool QuicConnection::ProcessValidatedPacket(const QuicPacketHeader& header) { |
1398 if (header.fec_flag) { | 1398 if (header.fec_flag) { |
1399 // Drop any FEC packet. | 1399 // Drop any FEC packet. |
1400 return false; | 1400 return false; |
1401 } | 1401 } |
1402 | 1402 |
1403 if (perspective_ == Perspective::IS_SERVER && | 1403 if (perspective_ == Perspective::IS_SERVER && |
1404 IsInitializedIPEndPoint(self_address_) && | 1404 IsInitializedIPEndPoint(self_address_) && |
1405 IsInitializedIPEndPoint(last_packet_destination_address_) && | 1405 IsInitializedIPEndPoint(last_packet_destination_address_) && |
1406 (!(self_address_ == last_packet_destination_address_))) { | 1406 (!(self_address_ == last_packet_destination_address_))) { |
1407 CloseConnection(QUIC_ERROR_MIGRATING_ADDRESS, | 1407 if (!FLAGS_quic_allow_server_address_change_for_mapped_ipv4) { |
1408 "Self address migration is not supported at the server.", | 1408 CloseConnection(QUIC_ERROR_MIGRATING_ADDRESS, |
1409 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); | 1409 "Self address migration is not supported at the server.", |
1410 return false; | 1410 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
| 1411 return false; |
| 1412 } |
| 1413 // Allow change between pure IPv4 and equivalent mapped IPv4 address. |
| 1414 IPAddress self_ip = self_address_.address(); |
| 1415 if (self_ip.IsIPv4MappedIPv6()) { |
| 1416 self_ip = ConvertIPv4MappedIPv6ToIPv4(self_ip); |
| 1417 } |
| 1418 IPAddress last_packet_destination_ip = |
| 1419 last_packet_destination_address_.address(); |
| 1420 if (last_packet_destination_ip.IsIPv4MappedIPv6()) { |
| 1421 last_packet_destination_ip = |
| 1422 ConvertIPv4MappedIPv6ToIPv4(last_packet_destination_ip); |
| 1423 } |
| 1424 if (self_address_.port() != last_packet_destination_address_.port() || |
| 1425 self_ip != last_packet_destination_ip) { |
| 1426 CloseConnection(QUIC_ERROR_MIGRATING_ADDRESS, |
| 1427 "Self address migration is not supported at the server.", |
| 1428 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
| 1429 return false; |
| 1430 } |
| 1431 self_address_ = last_packet_destination_address_; |
1411 } | 1432 } |
1412 | 1433 |
1413 if (!Near(header.packet_number, last_header_.packet_number)) { | 1434 if (!Near(header.packet_number, last_header_.packet_number)) { |
1414 DVLOG(1) << ENDPOINT << "Packet " << header.packet_number | 1435 DVLOG(1) << ENDPOINT << "Packet " << header.packet_number |
1415 << " out of bounds. Discarding"; | 1436 << " out of bounds. Discarding"; |
1416 CloseConnection(QUIC_INVALID_PACKET_HEADER, "packet number out of bounds.", | 1437 CloseConnection(QUIC_INVALID_PACKET_HEADER, "packet number out of bounds.", |
1417 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); | 1438 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
1418 return false; | 1439 return false; |
1419 } | 1440 } |
1420 | 1441 |
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2559 | 2580 |
2560 void QuicConnection::CheckIfApplicationLimited() { | 2581 void QuicConnection::CheckIfApplicationLimited() { |
2561 if (queued_packets_.empty() && | 2582 if (queued_packets_.empty() && |
2562 !sent_packet_manager_->HasPendingRetransmissions() && | 2583 !sent_packet_manager_->HasPendingRetransmissions() && |
2563 !visitor_->WillingAndAbleToWrite()) { | 2584 !visitor_->WillingAndAbleToWrite()) { |
2564 sent_packet_manager_->OnApplicationLimited(); | 2585 sent_packet_manager_->OnApplicationLimited(); |
2565 } | 2586 } |
2566 } | 2587 } |
2567 | 2588 |
2568 } // namespace net | 2589 } // namespace net |
OLD | NEW |