| 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/tools/quic/quic_dispatcher.h" | 5 #include "net/tools/quic/quic_dispatcher.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <ostream> | 8 #include <ostream> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "net/quic/core/crypto/crypto_handshake.h" | 12 #include "net/quic/core/crypto/crypto_handshake.h" |
| 13 #include "net/quic/core/crypto/quic_crypto_server_config.h" | 13 #include "net/quic/core/crypto/quic_crypto_server_config.h" |
| 14 #include "net/quic/core/crypto/quic_random.h" | 14 #include "net/quic/core/crypto/quic_random.h" |
| 15 #include "net/quic/core/quic_crypto_stream.h" | 15 #include "net/quic/core/quic_crypto_stream.h" |
| 16 #include "net/quic/core/quic_flags.h" | 16 #include "net/quic/core/quic_flags.h" |
| 17 #include "net/quic/core/quic_utils.h" | 17 #include "net/quic/core/quic_utils.h" |
| 18 #include "net/quic/platform/api/quic_logging.h" |
| 18 #include "net/quic/platform/api/quic_str_cat.h" | 19 #include "net/quic/platform/api/quic_str_cat.h" |
| 19 #include "net/quic/test_tools/crypto_test_utils.h" | 20 #include "net/quic/test_tools/crypto_test_utils.h" |
| 20 #include "net/quic/test_tools/fake_proof_source.h" | 21 #include "net/quic/test_tools/fake_proof_source.h" |
| 21 #include "net/quic/test_tools/quic_buffered_packet_store_peer.h" | 22 #include "net/quic/test_tools/quic_buffered_packet_store_peer.h" |
| 22 #include "net/quic/test_tools/quic_crypto_server_config_peer.h" | 23 #include "net/quic/test_tools/quic_crypto_server_config_peer.h" |
| 23 #include "net/quic/test_tools/quic_test_utils.h" | 24 #include "net/quic/test_tools/quic_test_utils.h" |
| 24 #include "net/quic/test_tools/quic_time_wait_list_manager_peer.h" | 25 #include "net/quic/test_tools/quic_time_wait_list_manager_peer.h" |
| 25 #include "net/test/gtest_util.h" | 26 #include "net/test/gtest_util.h" |
| 26 #include "net/tools/epoll_server/epoll_server.h" | 27 #include "net/tools/epoll_server/epoll_server.h" |
| 27 #include "net/tools/quic/chlo_extractor.h" | 28 #include "net/tools/quic/chlo_extractor.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 MockQuicConnectionHelper* helper, | 147 MockQuicConnectionHelper* helper, |
| 147 MockAlarmFactory* alarm_factory, | 148 MockAlarmFactory* alarm_factory, |
| 148 QuicDispatcher* dispatcher) | 149 QuicDispatcher* dispatcher) |
| 149 : MockQuicConnection(connection_id, | 150 : MockQuicConnection(connection_id, |
| 150 helper, | 151 helper, |
| 151 alarm_factory, | 152 alarm_factory, |
| 152 Perspective::IS_SERVER), | 153 Perspective::IS_SERVER), |
| 153 dispatcher_(dispatcher) {} | 154 dispatcher_(dispatcher) {} |
| 154 | 155 |
| 155 void UnregisterOnConnectionClosed() { | 156 void UnregisterOnConnectionClosed() { |
| 156 LOG(ERROR) << "Unregistering " << connection_id(); | 157 QUIC_LOG(ERROR) << "Unregistering " << connection_id(); |
| 157 dispatcher_->OnConnectionClosed(connection_id(), QUIC_NO_ERROR, | 158 dispatcher_->OnConnectionClosed(connection_id(), QUIC_NO_ERROR, |
| 158 "Unregistering."); | 159 "Unregistering."); |
| 159 } | 160 } |
| 160 | 161 |
| 161 private: | 162 private: |
| 162 QuicDispatcher* dispatcher_; | 163 QuicDispatcher* dispatcher_; |
| 163 }; | 164 }; |
| 164 | 165 |
| 165 class QuicDispatcherTest : public ::testing::Test { | 166 class QuicDispatcherTest : public ::testing::Test { |
| 166 public: | 167 public: |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 } else { | 808 } else { |
| 808 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address)) | 809 EXPECT_CALL(*dispatcher_, CreateQuicSession(connection_id, client_address)) |
| 809 .WillOnce(testing::Return( | 810 .WillOnce(testing::Return( |
| 810 CreateSessionBasedOnTestParams(connection_id, client_address))); | 811 CreateSessionBasedOnTestParams(connection_id, client_address))); |
| 811 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), | 812 EXPECT_CALL(*reinterpret_cast<MockQuicConnection*>(session1_->connection()), |
| 812 ProcessUdpPacket(_, _, _)) | 813 ProcessUdpPacket(_, _, _)) |
| 813 .WillOnce(testing::WithArgs<2>(Invoke(CreateFunctor( | 814 .WillOnce(testing::WithArgs<2>(Invoke(CreateFunctor( |
| 814 &QuicDispatcherTest::ValidatePacket, base::Unretained(this), 1)))); | 815 &QuicDispatcherTest::ValidatePacket, base::Unretained(this), 1)))); |
| 815 } | 816 } |
| 816 | 817 |
| 817 VLOG(1) << "ExpectStatelessReject: " << ExpectStatelessReject(); | 818 QUIC_LOG(INFO) << "ExpectStatelessReject: " << ExpectStatelessReject(); |
| 818 VLOG(1) << "Params: " << GetParam(); | 819 QUIC_LOG(INFO) << "Params: " << GetParam(); |
| 819 // Process the first packet for the connection. | 820 // Process the first packet for the connection. |
| 820 // clang-format off | 821 // clang-format off |
| 821 CryptoHandshakeMessage client_hello = CryptoTestUtils::Message( | 822 CryptoHandshakeMessage client_hello = CryptoTestUtils::Message( |
| 822 "CHLO", | 823 "CHLO", |
| 823 "AEAD", "AESG", | 824 "AEAD", "AESG", |
| 824 "KEXS", "C255", | 825 "KEXS", "C255", |
| 825 "COPT", "SREJ", | 826 "COPT", "SREJ", |
| 826 "NONC", "1234567890123456789012", | 827 "NONC", "1234567890123456789012", |
| 827 "VER\0", "Q025", | 828 "VER\0", "Q025", |
| 828 "$padding", static_cast<int>(kClientHelloMinimumSize), | 829 "$padding", static_cast<int>(kClientHelloMinimumSize), |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 914 void SetWritable() override { write_blocked_ = false; } | 915 void SetWritable() override { write_blocked_ = false; } |
| 915 | 916 |
| 916 WriteResult WritePacket(const char* buffer, | 917 WriteResult WritePacket(const char* buffer, |
| 917 size_t buf_len, | 918 size_t buf_len, |
| 918 const QuicIpAddress& self_client_address, | 919 const QuicIpAddress& self_client_address, |
| 919 const QuicSocketAddress& peer_client_address, | 920 const QuicSocketAddress& peer_client_address, |
| 920 PerPacketOptions* options) override { | 921 PerPacketOptions* options) override { |
| 921 // It would be quite possible to actually implement this method here with | 922 // It would be quite possible to actually implement this method here with |
| 922 // the fake blocked status, but it would be significantly more work in | 923 // the fake blocked status, but it would be significantly more work in |
| 923 // Chromium, and since it's not called anyway, don't bother. | 924 // Chromium, and since it's not called anyway, don't bother. |
| 924 LOG(DFATAL) << "Not supported"; | 925 QUIC_LOG(DFATAL) << "Not supported"; |
| 925 return WriteResult(); | 926 return WriteResult(); |
| 926 } | 927 } |
| 927 | 928 |
| 928 bool write_blocked_; | 929 bool write_blocked_; |
| 929 }; | 930 }; |
| 930 | 931 |
| 931 class QuicDispatcherWriteBlockedListTest : public QuicDispatcherTest { | 932 class QuicDispatcherWriteBlockedListTest : public QuicDispatcherTest { |
| 932 public: | 933 public: |
| 933 void SetUp() override { | 934 void SetUp() override { |
| 934 QuicDispatcherTest::SetUp(); | 935 QuicDispatcherTest::SetUp(); |
| (...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2080 check.Call(2); | 2081 check.Call(2); |
| 2081 GetFakeProofSource()->InvokePendingCallback(0); | 2082 GetFakeProofSource()->InvokePendingCallback(0); |
| 2082 ASSERT_EQ(GetFakeProofSource()->NumPendingCallbacks(), 0); | 2083 ASSERT_EQ(GetFakeProofSource()->NumPendingCallbacks(), 0); |
| 2083 EXPECT_FALSE(store->HasBufferedPackets(conn_id)); | 2084 EXPECT_FALSE(store->HasBufferedPackets(conn_id)); |
| 2084 EXPECT_FALSE(time_wait_list_manager_->IsConnectionIdInTimeWait(conn_id)); | 2085 EXPECT_FALSE(time_wait_list_manager_->IsConnectionIdInTimeWait(conn_id)); |
| 2085 } | 2086 } |
| 2086 | 2087 |
| 2087 } // namespace | 2088 } // namespace |
| 2088 } // namespace test | 2089 } // namespace test |
| 2089 } // namespace net | 2090 } // namespace net |
| OLD | NEW |