| 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 <cstdint> | 7 #include <cstdint> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 #include "net/quic/core/crypto/crypto_framer.h" | 14 #include "net/quic/core/crypto/crypto_framer.h" |
| 15 #include "net/quic/core/crypto/crypto_handshake_message.h" | 15 #include "net/quic/core/crypto/crypto_handshake_message.h" |
| 16 #include "net/quic/core/crypto/crypto_protocol.h" | 16 #include "net/quic/core/crypto/crypto_protocol.h" |
| 17 #include "net/quic/core/crypto/null_decrypter.h" | 17 #include "net/quic/core/crypto/null_decrypter.h" |
| 18 #include "net/quic/core/crypto/null_encrypter.h" | 18 #include "net/quic/core/crypto/null_encrypter.h" |
| 19 #include "net/quic/core/crypto/quic_decrypter.h" | 19 #include "net/quic/core/crypto/quic_decrypter.h" |
| 20 #include "net/quic/core/crypto/quic_encrypter.h" | 20 #include "net/quic/core/crypto/quic_encrypter.h" |
| 21 #include "net/quic/core/quic_bug_tracker.h" | 21 #include "net/quic/core/quic_bug_tracker.h" |
| 22 #include "net/quic/core/quic_data_reader.h" | 22 #include "net/quic/core/quic_data_reader.h" |
| 23 #include "net/quic/core/quic_data_writer.h" | 23 #include "net/quic/core/quic_data_writer.h" |
| 24 #include "net/quic/core/quic_flags.h" | 24 #include "net/quic/core/quic_flags.h" |
| 25 #include "net/quic/core/quic_socket_address_coder.h" | 25 #include "net/quic/core/quic_socket_address_coder.h" |
| 26 #include "net/quic/core/quic_utils.h" | 26 #include "net/quic/core/quic_utils.h" |
| 27 #include "net/quic/platform/api/quic_aligned.h" |
| 27 | 28 |
| 28 using base::ContainsKey; | 29 using base::ContainsKey; |
| 29 using base::StringPiece; | 30 using base::StringPiece; |
| 30 using std::string; | 31 using std::string; |
| 31 #define PREDICT_FALSE(x) (x) | 32 #define PREDICT_FALSE(x) (x) |
| 32 | 33 |
| 33 namespace net { | 34 namespace net { |
| 34 | 35 |
| 35 namespace { | 36 namespace { |
| 36 | 37 |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 } | 525 } |
| 525 | 526 |
| 526 bool rv; | 527 bool rv; |
| 527 if (perspective_ == Perspective::IS_CLIENT && public_header.version_flag) { | 528 if (perspective_ == Perspective::IS_CLIENT && public_header.version_flag) { |
| 528 rv = ProcessVersionNegotiationPacket(&reader, &public_header); | 529 rv = ProcessVersionNegotiationPacket(&reader, &public_header); |
| 529 } else if (public_header.reset_flag) { | 530 } else if (public_header.reset_flag) { |
| 530 rv = ProcessPublicResetPacket(&reader, public_header); | 531 rv = ProcessPublicResetPacket(&reader, public_header); |
| 531 } else if (packet.length() <= kMaxPacketSize) { | 532 } else if (packet.length() <= kMaxPacketSize) { |
| 532 // The optimized decryption algorithm implementations run faster when | 533 // The optimized decryption algorithm implementations run faster when |
| 533 // operating on aligned memory. | 534 // operating on aligned memory. |
| 534 // | 535 QUIC_CACHELINE_ALIGNED char buffer[kMaxPacketSize]; |
| 535 // TODO(rtenneti): Change the default 64 alignas value (used the default | |
| 536 // value from CACHELINE_SIZE). | |
| 537 ALIGNAS(64) char buffer[kMaxPacketSize]; | |
| 538 rv = ProcessDataPacket(&reader, public_header, packet, buffer, | 536 rv = ProcessDataPacket(&reader, public_header, packet, buffer, |
| 539 kMaxPacketSize); | 537 kMaxPacketSize); |
| 540 } else { | 538 } else { |
| 541 std::unique_ptr<char[]> large_buffer(new char[packet.length()]); | 539 std::unique_ptr<char[]> large_buffer(new char[packet.length()]); |
| 542 rv = ProcessDataPacket(&reader, public_header, packet, large_buffer.get(), | 540 rv = ProcessDataPacket(&reader, public_header, packet, large_buffer.get(), |
| 543 packet.length()); | 541 packet.length()); |
| 544 QUIC_BUG_IF(rv) << "QUIC should never successfully process packets larger" | 542 QUIC_BUG_IF(rv) << "QUIC should never successfully process packets larger" |
| 545 << "than kMaxPacketSize. packet size:" << packet.length(); | 543 << "than kMaxPacketSize. packet size:" << packet.length(); |
| 546 } | 544 } |
| 547 | 545 |
| (...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2202 | 2200 |
| 2203 bool QuicFramer::RaiseError(QuicErrorCode error) { | 2201 bool QuicFramer::RaiseError(QuicErrorCode error) { |
| 2204 DVLOG(1) << ENDPOINT << "Error: " << QuicErrorCodeToString(error) | 2202 DVLOG(1) << ENDPOINT << "Error: " << QuicErrorCodeToString(error) |
| 2205 << " detail: " << detailed_error_; | 2203 << " detail: " << detailed_error_; |
| 2206 set_error(error); | 2204 set_error(error); |
| 2207 visitor_->OnError(this); | 2205 visitor_->OnError(this); |
| 2208 return false; | 2206 return false; |
| 2209 } | 2207 } |
| 2210 | 2208 |
| 2211 } // namespace net | 2209 } // namespace net |
| OLD | NEW |