| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 QuicPathCloseFrame path_close_frame_; | 345 QuicPathCloseFrame path_close_frame_; |
| 346 vector<string*> stream_data_; | 346 vector<string*> stream_data_; |
| 347 }; | 347 }; |
| 348 | 348 |
| 349 class QuicFramerTest : public ::testing::TestWithParam<QuicVersion> { | 349 class QuicFramerTest : public ::testing::TestWithParam<QuicVersion> { |
| 350 public: | 350 public: |
| 351 QuicFramerTest() | 351 QuicFramerTest() |
| 352 : encrypter_(new test::TestEncrypter()), | 352 : encrypter_(new test::TestEncrypter()), |
| 353 decrypter_(new test::TestDecrypter()), | 353 decrypter_(new test::TestDecrypter()), |
| 354 start_(QuicTime::Zero() + QuicTime::Delta::FromMicroseconds(0x10)), | 354 start_(QuicTime::Zero() + QuicTime::Delta::FromMicroseconds(0x10)), |
| 355 framer_(QuicSupportedVersions(), start_, Perspective::IS_SERVER) { | 355 framer_(AllSupportedVersions(), start_, Perspective::IS_SERVER) { |
| 356 version_ = GetParam(); | 356 version_ = GetParam(); |
| 357 framer_.set_version(version_); | 357 framer_.set_version(version_); |
| 358 framer_.SetDecrypter(ENCRYPTION_NONE, decrypter_); | 358 framer_.SetDecrypter(ENCRYPTION_NONE, decrypter_); |
| 359 framer_.SetEncrypter(ENCRYPTION_NONE, encrypter_); | 359 framer_.SetEncrypter(ENCRYPTION_NONE, encrypter_); |
| 360 framer_.set_visitor(&visitor_); | 360 framer_.set_visitor(&visitor_); |
| 361 framer_.set_received_entropy_calculator(&entropy_calculator_); | 361 framer_.set_received_entropy_calculator(&entropy_calculator_); |
| 362 } | 362 } |
| 363 | 363 |
| 364 // Helper function to get unsigned char representation of digit in the | 364 // Helper function to get unsigned char representation of digit in the |
| 365 // units place of the current QUIC version number. | 365 // units place of the current QUIC version number. |
| (...skipping 6766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7132 } | 7132 } |
| 7133 | 7133 |
| 7134 // Tests for fuzzing with Dr. Fuzz | 7134 // Tests for fuzzing with Dr. Fuzz |
| 7135 // Xref http://www.chromium.org/developers/testing/dr-fuzz for more details. | 7135 // Xref http://www.chromium.org/developers/testing/dr-fuzz for more details. |
| 7136 #ifdef __cplusplus | 7136 #ifdef __cplusplus |
| 7137 extern "C" { | 7137 extern "C" { |
| 7138 #endif | 7138 #endif |
| 7139 | 7139 |
| 7140 // target function to be fuzzed by Dr. Fuzz | 7140 // target function to be fuzzed by Dr. Fuzz |
| 7141 void QuicFramerFuzzFunc(unsigned char* data, size_t size) { | 7141 void QuicFramerFuzzFunc(unsigned char* data, size_t size) { |
| 7142 QuicFramer framer(QuicSupportedVersions(), QuicTime::Zero(), | 7142 QuicFramer framer(AllSupportedVersions(), QuicTime::Zero(), |
| 7143 Perspective::IS_SERVER); | 7143 Perspective::IS_SERVER); |
| 7144 const char* const packet_bytes = reinterpret_cast<const char*>(data); | 7144 const char* const packet_bytes = reinterpret_cast<const char*>(data); |
| 7145 | 7145 |
| 7146 // Test the CryptoFramer. | 7146 // Test the CryptoFramer. |
| 7147 StringPiece crypto_input(packet_bytes, size); | 7147 StringPiece crypto_input(packet_bytes, size); |
| 7148 std::unique_ptr<CryptoHandshakeMessage> handshake_message( | 7148 std::unique_ptr<CryptoHandshakeMessage> handshake_message( |
| 7149 CryptoFramer::ParseMessage(crypto_input)); | 7149 CryptoFramer::ParseMessage(crypto_input)); |
| 7150 | 7150 |
| 7151 // Test the regular QuicFramer with the same input. | 7151 // Test the regular QuicFramer with the same input. |
| 7152 NoOpFramerVisitor visitor; | 7152 NoOpFramerVisitor visitor; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7187 'o', ' ', 'w', 'o', | 7187 'o', ' ', 'w', 'o', |
| 7188 'r', 'l', 'd', '!', | 7188 'r', 'l', 'd', '!', |
| 7189 }; | 7189 }; |
| 7190 // clang-format on | 7190 // clang-format on |
| 7191 | 7191 |
| 7192 QuicFramerFuzzFunc(packet, arraysize(packet)); | 7192 QuicFramerFuzzFunc(packet, arraysize(packet)); |
| 7193 } | 7193 } |
| 7194 | 7194 |
| 7195 } // namespace test | 7195 } // namespace test |
| 7196 } // namespace net | 7196 } // namespace net |
| OLD | NEW |