| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <sys/epoll.h> | 6 #include <sys/epoll.h> |
| 7 | 7 |
| 8 #include <cstdint> | 8 #include <cstdint> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 1985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1996 ASSERT_TRUE(Initialize()); | 1996 ASSERT_TRUE(Initialize()); |
| 1997 | 1997 |
| 1998 // Send the public reset. | 1998 // Send the public reset. |
| 1999 QuicConnectionId connection_id = | 1999 QuicConnectionId connection_id = |
| 2000 client_->client()->session()->connection()->connection_id(); | 2000 client_->client()->session()->connection()->connection_id(); |
| 2001 QuicPublicResetPacket header; | 2001 QuicPublicResetPacket header; |
| 2002 header.public_header.connection_id = | 2002 header.public_header.connection_id = |
| 2003 GetPeerInMemoryConnectionId(connection_id); | 2003 GetPeerInMemoryConnectionId(connection_id); |
| 2004 header.public_header.reset_flag = true; | 2004 header.public_header.reset_flag = true; |
| 2005 header.public_header.version_flag = false; | 2005 header.public_header.version_flag = false; |
| 2006 header.rejected_packet_number = 10101; | |
| 2007 QuicFramer framer(server_supported_versions_, QuicTime::Zero(), | 2006 QuicFramer framer(server_supported_versions_, QuicTime::Zero(), |
| 2008 Perspective::IS_SERVER); | 2007 Perspective::IS_SERVER); |
| 2009 std::unique_ptr<QuicEncryptedPacket> packet( | 2008 std::unique_ptr<QuicEncryptedPacket> packet( |
| 2010 framer.BuildPublicResetPacket(header)); | 2009 framer.BuildPublicResetPacket(header)); |
| 2011 // We must pause the server's thread in order to call WritePacket without | 2010 // We must pause the server's thread in order to call WritePacket without |
| 2012 // race conditions. | 2011 // race conditions. |
| 2013 server_thread_->Pause(); | 2012 server_thread_->Pause(); |
| 2014 server_writer_->WritePacket( | 2013 server_writer_->WritePacket( |
| 2015 packet->data(), packet->length(), server_address_.host(), | 2014 packet->data(), packet->length(), server_address_.host(), |
| 2016 client_->client()->GetLatestClientAddress(), nullptr); | 2015 client_->client()->GetLatestClientAddress(), nullptr); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2030 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed()); | 2029 EXPECT_TRUE(client_->client()->WaitForCryptoHandshakeConfirmed()); |
| 2031 | 2030 |
| 2032 // Send the public reset. | 2031 // Send the public reset. |
| 2033 QuicConnectionId incorrect_connection_id = | 2032 QuicConnectionId incorrect_connection_id = |
| 2034 client_->client()->session()->connection()->connection_id() + 1; | 2033 client_->client()->session()->connection()->connection_id() + 1; |
| 2035 QuicPublicResetPacket header; | 2034 QuicPublicResetPacket header; |
| 2036 header.public_header.connection_id = | 2035 header.public_header.connection_id = |
| 2037 GetPeerInMemoryConnectionId(incorrect_connection_id); | 2036 GetPeerInMemoryConnectionId(incorrect_connection_id); |
| 2038 header.public_header.reset_flag = true; | 2037 header.public_header.reset_flag = true; |
| 2039 header.public_header.version_flag = false; | 2038 header.public_header.version_flag = false; |
| 2040 header.rejected_packet_number = 10101; | |
| 2041 QuicFramer framer(server_supported_versions_, QuicTime::Zero(), | 2039 QuicFramer framer(server_supported_versions_, QuicTime::Zero(), |
| 2042 Perspective::IS_SERVER); | 2040 Perspective::IS_SERVER); |
| 2043 std::unique_ptr<QuicEncryptedPacket> packet( | 2041 std::unique_ptr<QuicEncryptedPacket> packet( |
| 2044 framer.BuildPublicResetPacket(header)); | 2042 framer.BuildPublicResetPacket(header)); |
| 2045 testing::NiceMock<MockQuicConnectionDebugVisitor> visitor; | 2043 testing::NiceMock<MockQuicConnectionDebugVisitor> visitor; |
| 2046 client_->client()->session()->connection()->set_debug_visitor(&visitor); | 2044 client_->client()->session()->connection()->set_debug_visitor(&visitor); |
| 2047 EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id)) | 2045 EXPECT_CALL(visitor, OnIncorrectConnectionId(incorrect_connection_id)) |
| 2048 .Times(1); | 2046 .Times(1); |
| 2049 // We must pause the server's thread in order to call WritePacket without | 2047 // We must pause the server's thread in order to call WritePacket without |
| 2050 // race conditions. | 2048 // race conditions. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2066 TEST_P(EndToEndTest, ClientSendPublicResetWithDifferentConnectionId) { | 2064 TEST_P(EndToEndTest, ClientSendPublicResetWithDifferentConnectionId) { |
| 2067 ASSERT_TRUE(Initialize()); | 2065 ASSERT_TRUE(Initialize()); |
| 2068 | 2066 |
| 2069 // Send the public reset. | 2067 // Send the public reset. |
| 2070 QuicConnectionId incorrect_connection_id = | 2068 QuicConnectionId incorrect_connection_id = |
| 2071 client_->client()->session()->connection()->connection_id() + 1; | 2069 client_->client()->session()->connection()->connection_id() + 1; |
| 2072 QuicPublicResetPacket header; | 2070 QuicPublicResetPacket header; |
| 2073 header.public_header.connection_id = incorrect_connection_id; | 2071 header.public_header.connection_id = incorrect_connection_id; |
| 2074 header.public_header.reset_flag = true; | 2072 header.public_header.reset_flag = true; |
| 2075 header.public_header.version_flag = false; | 2073 header.public_header.version_flag = false; |
| 2076 header.rejected_packet_number = 10101; | |
| 2077 QuicFramer framer(server_supported_versions_, QuicTime::Zero(), | 2074 QuicFramer framer(server_supported_versions_, QuicTime::Zero(), |
| 2078 Perspective::IS_CLIENT); | 2075 Perspective::IS_CLIENT); |
| 2079 std::unique_ptr<QuicEncryptedPacket> packet( | 2076 std::unique_ptr<QuicEncryptedPacket> packet( |
| 2080 framer.BuildPublicResetPacket(header)); | 2077 framer.BuildPublicResetPacket(header)); |
| 2081 client_writer_->WritePacket( | 2078 client_writer_->WritePacket( |
| 2082 packet->data(), packet->length(), | 2079 packet->data(), packet->length(), |
| 2083 client_->client()->GetLatestClientAddress().host(), server_address_, | 2080 client_->client()->GetLatestClientAddress().host(), server_address_, |
| 2084 nullptr); | 2081 nullptr); |
| 2085 | 2082 |
| 2086 // The connection should be unaffected. | 2083 // The connection should be unaffected. |
| (...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3070 client_->WaitForResponse(); | 3067 client_->WaitForResponse(); |
| 3071 EXPECT_EQ(kBarResponseBody, client_->response_body()); | 3068 EXPECT_EQ(kBarResponseBody, client_->response_body()); |
| 3072 QuicConnectionStats client_stats = | 3069 QuicConnectionStats client_stats = |
| 3073 client_->client()->session()->connection()->GetStats(); | 3070 client_->client()->session()->connection()->GetStats(); |
| 3074 EXPECT_EQ(0u, client_stats.packets_lost); | 3071 EXPECT_EQ(0u, client_stats.packets_lost); |
| 3075 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); | 3072 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); |
| 3076 } | 3073 } |
| 3077 } // namespace | 3074 } // namespace |
| 3078 } // namespace test | 3075 } // namespace test |
| 3079 } // namespace net | 3076 } // namespace net |
| OLD | NEW |