| 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 "net/quic/core/crypto/crypto_framer.h" | 11 #include "net/quic/core/crypto/crypto_framer.h" |
| 12 #include "net/quic/core/crypto/crypto_handshake_message.h" | 12 #include "net/quic/core/crypto/crypto_handshake_message.h" |
| 13 #include "net/quic/core/crypto/crypto_protocol.h" | 13 #include "net/quic/core/crypto/crypto_protocol.h" |
| 14 #include "net/quic/core/crypto/null_decrypter.h" | 14 #include "net/quic/core/crypto/null_decrypter.h" |
| 15 #include "net/quic/core/crypto/null_encrypter.h" | 15 #include "net/quic/core/crypto/null_encrypter.h" |
| 16 #include "net/quic/core/crypto/quic_decrypter.h" | 16 #include "net/quic/core/crypto/quic_decrypter.h" |
| 17 #include "net/quic/core/crypto/quic_encrypter.h" | 17 #include "net/quic/core/crypto/quic_encrypter.h" |
| 18 #include "net/quic/core/quic_data_reader.h" | 18 #include "net/quic/core/quic_data_reader.h" |
| 19 #include "net/quic/core/quic_data_writer.h" | 19 #include "net/quic/core/quic_data_writer.h" |
| 20 #include "net/quic/core/quic_flags.h" | 20 #include "net/quic/core/quic_flags.h" |
| 21 #include "net/quic/core/quic_socket_address_coder.h" | 21 #include "net/quic/core/quic_socket_address_coder.h" |
| 22 #include "net/quic/core/quic_utils.h" | 22 #include "net/quic/core/quic_utils.h" |
| 23 #include "net/quic/platform/api/quic_aligned.h" | 23 #include "net/quic/platform/api/quic_aligned.h" |
| 24 #include "net/quic/platform/api/quic_bug_tracker.h" | 24 #include "net/quic/platform/api/quic_bug_tracker.h" |
| 25 #include "net/quic/platform/api/quic_flag_utils.h" |
| 25 #include "net/quic/platform/api/quic_logging.h" | 26 #include "net/quic/platform/api/quic_logging.h" |
| 26 #include "net/quic/platform/api/quic_map_util.h" | 27 #include "net/quic/platform/api/quic_map_util.h" |
| 27 #include "net/quic/platform/api/quic_ptr_util.h" | 28 #include "net/quic/platform/api/quic_ptr_util.h" |
| 28 | 29 |
| 29 using std::string; | 30 using std::string; |
| 30 | 31 |
| 31 namespace net { | 32 namespace net { |
| 32 | 33 |
| 33 namespace { | 34 namespace { |
| 34 | 35 |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 public_header->multipath_flag = | 770 public_header->multipath_flag = |
| 770 (public_flags & PACKET_PUBLIC_FLAGS_MULTIPATH) != 0; | 771 (public_flags & PACKET_PUBLIC_FLAGS_MULTIPATH) != 0; |
| 771 public_header->reset_flag = (public_flags & PACKET_PUBLIC_FLAGS_RST) != 0; | 772 public_header->reset_flag = (public_flags & PACKET_PUBLIC_FLAGS_RST) != 0; |
| 772 public_header->version_flag = | 773 public_header->version_flag = |
| 773 (public_flags & PACKET_PUBLIC_FLAGS_VERSION) != 0; | 774 (public_flags & PACKET_PUBLIC_FLAGS_VERSION) != 0; |
| 774 | 775 |
| 775 if (validate_flags_ && !public_header->version_flag && | 776 if (validate_flags_ && !public_header->version_flag && |
| 776 public_flags > (FLAGS_quic_reloadable_flag_quic_remove_multipath_bit | 777 public_flags > (FLAGS_quic_reloadable_flag_quic_remove_multipath_bit |
| 777 ? PACKET_PUBLIC_FLAGS_MAX_WITHOUT_MULTIPATH_FLAG | 778 ? PACKET_PUBLIC_FLAGS_MAX_WITHOUT_MULTIPATH_FLAG |
| 778 : PACKET_PUBLIC_FLAGS_MAX)) { | 779 : PACKET_PUBLIC_FLAGS_MAX)) { |
| 780 if (FLAGS_quic_reloadable_flag_quic_remove_multipath_bit) { |
| 781 QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_remove_multipath_bit, 1, 2); |
| 782 } |
| 779 set_detailed_error("Illegal public flags value."); | 783 set_detailed_error("Illegal public flags value."); |
| 780 return false; | 784 return false; |
| 781 } | 785 } |
| 782 | 786 |
| 783 if (public_header->reset_flag && public_header->version_flag) { | 787 if (public_header->reset_flag && public_header->version_flag) { |
| 784 set_detailed_error("Got version flag in reset packet"); | 788 set_detailed_error("Got version flag in reset packet"); |
| 785 return false; | 789 return false; |
| 786 } | 790 } |
| 787 | 791 |
| 788 switch (public_flags & PACKET_PUBLIC_FLAGS_8BYTE_CONNECTION_ID) { | 792 switch (public_flags & PACKET_PUBLIC_FLAGS_8BYTE_CONNECTION_ID) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 813 | 817 |
| 814 // If the version from the new packet is the same as the version of this | 818 // If the version from the new packet is the same as the version of this |
| 815 // framer, then the public flags should be set to something we understand. | 819 // framer, then the public flags should be set to something we understand. |
| 816 // If not, this raises an error. | 820 // If not, this raises an error. |
| 817 last_version_tag_ = version_tag; | 821 last_version_tag_ = version_tag; |
| 818 QuicVersion version = QuicTagToQuicVersion(version_tag); | 822 QuicVersion version = QuicTagToQuicVersion(version_tag); |
| 819 if (version == quic_version_ && | 823 if (version == quic_version_ && |
| 820 public_flags > (FLAGS_quic_reloadable_flag_quic_remove_multipath_bit | 824 public_flags > (FLAGS_quic_reloadable_flag_quic_remove_multipath_bit |
| 821 ? PACKET_PUBLIC_FLAGS_MAX_WITHOUT_MULTIPATH_FLAG | 825 ? PACKET_PUBLIC_FLAGS_MAX_WITHOUT_MULTIPATH_FLAG |
| 822 : PACKET_PUBLIC_FLAGS_MAX)) { | 826 : PACKET_PUBLIC_FLAGS_MAX)) { |
| 827 if (FLAGS_quic_reloadable_flag_quic_remove_multipath_bit) { |
| 828 QUIC_FLAG_COUNT_N(quic_reloadable_flag_quic_remove_multipath_bit, 1, 2); |
| 829 } |
| 823 set_detailed_error("Illegal public flags value."); | 830 set_detailed_error("Illegal public flags value."); |
| 824 return false; | 831 return false; |
| 825 } | 832 } |
| 826 public_header->versions.push_back(version); | 833 public_header->versions.push_back(version); |
| 827 } | 834 } |
| 828 | 835 |
| 829 // A nonce should only be present in packets from the server to the client, | 836 // A nonce should only be present in packets from the server to the client, |
| 830 // which are neither version negotiation nor public reset packets. | 837 // which are neither version negotiation nor public reset packets. |
| 831 if (public_flags & PACKET_PUBLIC_FLAGS_NONCE && | 838 if (public_flags & PACKET_PUBLIC_FLAGS_NONCE && |
| 832 !(public_flags & PACKET_PUBLIC_FLAGS_VERSION) && | 839 !(public_flags & PACKET_PUBLIC_FLAGS_VERSION) && |
| (...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2105 | 2112 |
| 2106 bool QuicFramer::RaiseError(QuicErrorCode error) { | 2113 bool QuicFramer::RaiseError(QuicErrorCode error) { |
| 2107 QUIC_DLOG(INFO) << ENDPOINT << "Error: " << QuicErrorCodeToString(error) | 2114 QUIC_DLOG(INFO) << ENDPOINT << "Error: " << QuicErrorCodeToString(error) |
| 2108 << " detail: " << detailed_error_; | 2115 << " detail: " << detailed_error_; |
| 2109 set_error(error); | 2116 set_error(error); |
| 2110 visitor_->OnError(this); | 2117 visitor_->OnError(this); |
| 2111 return false; | 2118 return false; |
| 2112 } | 2119 } |
| 2113 | 2120 |
| 2114 } // namespace net | 2121 } // namespace net |
| OLD | NEW |