OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_time_wait_list_manager.h" | 5 #include "net/tools/quic/quic_time_wait_list_manager.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 | 8 |
9 #include "net/quic/crypto/crypto_protocol.h" | 9 #include "net/quic/crypto/crypto_protocol.h" |
10 #include "net/quic/crypto/null_encrypter.h" | 10 #include "net/quic/crypto/null_encrypter.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 }; | 181 }; |
182 | 182 |
183 class ValidatePublicResetPacketPredicate | 183 class ValidatePublicResetPacketPredicate |
184 : public MatcherInterface<const std::tr1::tuple<const char*, int> > { | 184 : public MatcherInterface<const std::tr1::tuple<const char*, int> > { |
185 public: | 185 public: |
186 explicit ValidatePublicResetPacketPredicate(QuicConnectionId connection_id, | 186 explicit ValidatePublicResetPacketPredicate(QuicConnectionId connection_id, |
187 QuicPacketSequenceNumber number) | 187 QuicPacketSequenceNumber number) |
188 : connection_id_(connection_id), sequence_number_(number) { | 188 : connection_id_(connection_id), sequence_number_(number) { |
189 } | 189 } |
190 | 190 |
191 virtual bool MatchAndExplain( | 191 bool MatchAndExplain( |
192 const std::tr1::tuple<const char*, int> packet_buffer, | 192 const std::tr1::tuple<const char*, int> packet_buffer, |
193 testing::MatchResultListener* /* listener */) const override { | 193 testing::MatchResultListener* /* listener */) const override { |
194 FramerVisitorCapturingPublicReset visitor; | 194 FramerVisitorCapturingPublicReset visitor; |
195 QuicFramer framer(QuicSupportedVersions(), QuicTime::Zero(), | 195 QuicFramer framer(QuicSupportedVersions(), QuicTime::Zero(), |
196 Perspective::IS_CLIENT); | 196 Perspective::IS_CLIENT); |
197 framer.set_visitor(&visitor); | 197 framer.set_visitor(&visitor); |
198 QuicEncryptedPacket encrypted(std::tr1::get<0>(packet_buffer), | 198 QuicEncryptedPacket encrypted(std::tr1::get<0>(packet_buffer), |
199 std::tr1::get<1>(packet_buffer)); | 199 std::tr1::get<1>(packet_buffer)); |
200 framer.ProcessPacket(encrypted); | 200 framer.ProcessPacket(encrypted); |
201 QuicPublicResetPacket packet = visitor.public_reset_packet(); | 201 QuicPublicResetPacket packet = visitor.public_reset_packet(); |
202 return connection_id_ == packet.public_header.connection_id && | 202 return connection_id_ == packet.public_header.connection_id && |
203 packet.public_header.reset_flag && !packet.public_header.version_flag && | 203 packet.public_header.reset_flag && !packet.public_header.version_flag && |
204 sequence_number_ == packet.rejected_sequence_number && | 204 sequence_number_ == packet.rejected_sequence_number && |
205 net::test::TestPeerIPAddress() == packet.client_address.address() && | 205 net::test::TestPeerIPAddress() == packet.client_address.address() && |
206 kTestPort == packet.client_address.port(); | 206 kTestPort == packet.client_address.port(); |
207 } | 207 } |
208 | 208 |
209 virtual void DescribeTo(::std::ostream* os) const override {} | 209 void DescribeTo(::std::ostream* os) const override {} |
210 | 210 |
211 virtual void DescribeNegationTo(::std::ostream* os) const override {} | 211 void DescribeNegationTo(::std::ostream* os) const override {} |
212 | 212 |
213 private: | 213 private: |
214 QuicConnectionId connection_id_; | 214 QuicConnectionId connection_id_; |
215 QuicPacketSequenceNumber sequence_number_; | 215 QuicPacketSequenceNumber sequence_number_; |
216 }; | 216 }; |
217 | 217 |
218 | 218 |
219 Matcher<const std::tr1::tuple<const char*, int> > PublicResetPacketEq( | 219 Matcher<const std::tr1::tuple<const char*, int> > PublicResetPacketEq( |
220 QuicConnectionId connection_id, | 220 QuicConnectionId connection_id, |
221 QuicPacketSequenceNumber sequence_number) { | 221 QuicPacketSequenceNumber sequence_number) { |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 time_wait_list_manager_.num_connections()); | 527 time_wait_list_manager_.num_connections()); |
528 EXPECT_FALSE(IsConnectionIdInTimeWait(id_to_evict)); | 528 EXPECT_FALSE(IsConnectionIdInTimeWait(id_to_evict)); |
529 EXPECT_TRUE(IsConnectionIdInTimeWait(current_connection_id)); | 529 EXPECT_TRUE(IsConnectionIdInTimeWait(current_connection_id)); |
530 } | 530 } |
531 } | 531 } |
532 | 532 |
533 } // namespace | 533 } // namespace |
534 } // namespace test | 534 } // namespace test |
535 } // namespace tools | 535 } // namespace tools |
536 } // namespace net | 536 } // namespace net |
OLD | NEW |