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_framer.h" | 5 #include "net/quic/core/quic_framer.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 int packet_count_; | 315 int packet_count_; |
316 int frame_count_; | 316 int frame_count_; |
317 int complete_packets_; | 317 int complete_packets_; |
318 bool accept_packet_; | 318 bool accept_packet_; |
319 bool accept_public_header_; | 319 bool accept_public_header_; |
320 | 320 |
321 std::unique_ptr<QuicPacketHeader> header_; | 321 std::unique_ptr<QuicPacketHeader> header_; |
322 std::unique_ptr<QuicPacketPublicHeader> public_header_; | 322 std::unique_ptr<QuicPacketPublicHeader> public_header_; |
323 std::unique_ptr<QuicPublicResetPacket> public_reset_packet_; | 323 std::unique_ptr<QuicPublicResetPacket> public_reset_packet_; |
324 std::unique_ptr<QuicVersionNegotiationPacket> version_negotiation_packet_; | 324 std::unique_ptr<QuicVersionNegotiationPacket> version_negotiation_packet_; |
325 vector<std::unique_ptr<QuicStreamFrame>> stream_frames_; | 325 std::vector<std::unique_ptr<QuicStreamFrame>> stream_frames_; |
326 vector<std::unique_ptr<QuicAckFrame>> ack_frames_; | 326 std::vector<std::unique_ptr<QuicAckFrame>> ack_frames_; |
327 vector<std::unique_ptr<QuicStopWaitingFrame>> stop_waiting_frames_; | 327 std::vector<std::unique_ptr<QuicStopWaitingFrame>> stop_waiting_frames_; |
328 vector<std::unique_ptr<QuicPaddingFrame>> padding_frames_; | 328 std::vector<std::unique_ptr<QuicPaddingFrame>> padding_frames_; |
329 vector<std::unique_ptr<QuicPingFrame>> ping_frames_; | 329 std::vector<std::unique_ptr<QuicPingFrame>> ping_frames_; |
330 QuicRstStreamFrame rst_stream_frame_; | 330 QuicRstStreamFrame rst_stream_frame_; |
331 QuicConnectionCloseFrame connection_close_frame_; | 331 QuicConnectionCloseFrame connection_close_frame_; |
332 QuicGoAwayFrame goaway_frame_; | 332 QuicGoAwayFrame goaway_frame_; |
333 QuicWindowUpdateFrame window_update_frame_; | 333 QuicWindowUpdateFrame window_update_frame_; |
334 QuicBlockedFrame blocked_frame_; | 334 QuicBlockedFrame blocked_frame_; |
335 QuicPathCloseFrame path_close_frame_; | 335 QuicPathCloseFrame path_close_frame_; |
336 vector<std::unique_ptr<string>> stream_data_; | 336 std::vector<std::unique_ptr<string>> stream_data_; |
337 }; | 337 }; |
338 | 338 |
339 class QuicFramerTest : public ::testing::TestWithParam<QuicVersion> { | 339 class QuicFramerTest : public ::testing::TestWithParam<QuicVersion> { |
340 public: | 340 public: |
341 QuicFramerTest() | 341 QuicFramerTest() |
342 : encrypter_(new test::TestEncrypter()), | 342 : encrypter_(new test::TestEncrypter()), |
343 decrypter_(new test::TestDecrypter()), | 343 decrypter_(new test::TestDecrypter()), |
344 start_(QuicTime::Zero() + QuicTime::Delta::FromMicroseconds(0x10)), | 344 start_(QuicTime::Zero() + QuicTime::Delta::FromMicroseconds(0x10)), |
345 framer_(AllSupportedVersions(), start_, Perspective::IS_SERVER) { | 345 framer_(AllSupportedVersions(), start_, Perspective::IS_SERVER) { |
346 version_ = GetParam(); | 346 version_ = GetParam(); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 | 575 |
576 // but large numbers should not (even if they're out of order). | 576 // but large numbers should not (even if they're out of order). |
577 for (uint64_t j = 0; j < 10; j++) { | 577 for (uint64_t j = 0; j < 10; j++) { |
578 uint64_t num = kEpoch - 1 - j; | 578 uint64_t num = kEpoch - 1 - j; |
579 CheckCalculatePacketNumber(cur_epoch + num, last); | 579 CheckCalculatePacketNumber(cur_epoch + num, last); |
580 } | 580 } |
581 } | 581 } |
582 } | 582 } |
583 | 583 |
584 TEST_P(QuicFramerTest, CalculatePacketNumberFromWireNearNextMax) { | 584 TEST_P(QuicFramerTest, CalculatePacketNumberFromWireNearNextMax) { |
585 const uint64_t max_number = numeric_limits<uint64_t>::max(); | 585 const uint64_t max_number = std::numeric_limits<uint64_t>::max(); |
586 const uint64_t max_epoch = max_number & ~kMask; | 586 const uint64_t max_epoch = max_number & ~kMask; |
587 | 587 |
588 // Cases where the last number was close to the end of the range | 588 // Cases where the last number was close to the end of the range |
589 for (uint64_t i = 0; i < 10; i++) { | 589 for (uint64_t i = 0; i < 10; i++) { |
590 // Subtract 1, because the expected next packet number is 1 more than the | 590 // Subtract 1, because the expected next packet number is 1 more than the |
591 // last packet number. | 591 // last packet number. |
592 QuicPacketNumber last = max_number - i - 1; | 592 QuicPacketNumber last = max_number - i - 1; |
593 | 593 |
594 // Small numbers should not wrap, because they have nowhere to go. | 594 // Small numbers should not wrap, because they have nowhere to go. |
595 for (uint64_t j = 0; j < 10; j++) { | 595 for (uint64_t j = 0; j < 10; j++) { |
(...skipping 5877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6473 'o', ' ', 'w', 'o', | 6473 'o', ' ', 'w', 'o', |
6474 'r', 'l', 'd', '!', | 6474 'r', 'l', 'd', '!', |
6475 }; | 6475 }; |
6476 // clang-format on | 6476 // clang-format on |
6477 | 6477 |
6478 QuicFramerFuzzFunc(packet, arraysize(packet)); | 6478 QuicFramerFuzzFunc(packet, arraysize(packet)); |
6479 } | 6479 } |
6480 | 6480 |
6481 } // namespace test | 6481 } // namespace test |
6482 } // namespace net | 6482 } // namespace net |
OLD | NEW |