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_protocol.h" | 5 #include "net/quic/core/quic_protocol.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "net/quic/core/quic_flags.h" | 9 #include "net/quic/core/quic_flags.h" |
10 #include "net/quic/core/quic_utils.h" | 10 #include "net/quic/core/quic_utils.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 } | 180 } |
181 | 181 |
182 QuicVersionVector CurrentSupportedVersions() { | 182 QuicVersionVector CurrentSupportedVersions() { |
183 return FilterSupportedVersions(AllSupportedVersions()); | 183 return FilterSupportedVersions(AllSupportedVersions()); |
184 } | 184 } |
185 | 185 |
186 QuicVersionVector FilterSupportedVersions(QuicVersionVector versions) { | 186 QuicVersionVector FilterSupportedVersions(QuicVersionVector versions) { |
187 QuicVersionVector filtered_versions(versions.size()); | 187 QuicVersionVector filtered_versions(versions.size()); |
188 filtered_versions.clear(); // Guaranteed by spec not to change capacity. | 188 filtered_versions.clear(); // Guaranteed by spec not to change capacity. |
189 for (QuicVersion version : versions) { | 189 for (QuicVersion version : versions) { |
190 if (version < QUIC_VERSION_32) { | 190 if (version < QUIC_VERSION_34) { |
191 if (!FLAGS_quic_disable_pre_32 && !FLAGS_quic_disable_pre_34) { | |
192 filtered_versions.push_back(version); | |
193 } | |
194 } else if (version < QUIC_VERSION_34) { | |
195 if (!FLAGS_quic_disable_pre_34) { | 191 if (!FLAGS_quic_disable_pre_34) { |
196 filtered_versions.push_back(version); | 192 filtered_versions.push_back(version); |
197 } | 193 } |
198 } else if (version == QUIC_VERSION_35) { | 194 } else if (version == QUIC_VERSION_35) { |
199 if (FLAGS_quic_enable_version_35) { | 195 if (FLAGS_quic_enable_version_35) { |
200 filtered_versions.push_back(version); | 196 filtered_versions.push_back(version); |
201 } | 197 } |
202 } else if (version == QUIC_VERSION_36) { | 198 } else if (version == QUIC_VERSION_36) { |
203 if (FLAGS_quic_enable_version_35 && FLAGS_quic_enable_version_36_v2) { | 199 if (FLAGS_quic_enable_version_35 && FLAGS_quic_enable_version_36_v2) { |
204 filtered_versions.push_back(version); | 200 filtered_versions.push_back(version); |
(...skipping 11 matching lines...) Expand all Loading... |
216 if (index >= 0 && index < version_count) { | 212 if (index >= 0 && index < version_count) { |
217 version.push_back(versions[index]); | 213 version.push_back(versions[index]); |
218 } else { | 214 } else { |
219 version.push_back(QUIC_VERSION_UNSUPPORTED); | 215 version.push_back(QUIC_VERSION_UNSUPPORTED); |
220 } | 216 } |
221 return version; | 217 return version; |
222 } | 218 } |
223 | 219 |
224 QuicTag QuicVersionToQuicTag(const QuicVersion version) { | 220 QuicTag QuicVersionToQuicTag(const QuicVersion version) { |
225 switch (version) { | 221 switch (version) { |
226 case QUIC_VERSION_30: | |
227 return MakeQuicTag('Q', '0', '3', '0'); | |
228 case QUIC_VERSION_31: | |
229 return MakeQuicTag('Q', '0', '3', '1'); | |
230 case QUIC_VERSION_32: | 222 case QUIC_VERSION_32: |
231 return MakeQuicTag('Q', '0', '3', '2'); | 223 return MakeQuicTag('Q', '0', '3', '2'); |
232 case QUIC_VERSION_33: | 224 case QUIC_VERSION_33: |
233 return MakeQuicTag('Q', '0', '3', '3'); | 225 return MakeQuicTag('Q', '0', '3', '3'); |
234 case QUIC_VERSION_34: | 226 case QUIC_VERSION_34: |
235 return MakeQuicTag('Q', '0', '3', '4'); | 227 return MakeQuicTag('Q', '0', '3', '4'); |
236 case QUIC_VERSION_35: | 228 case QUIC_VERSION_35: |
237 return MakeQuicTag('Q', '0', '3', '5'); | 229 return MakeQuicTag('Q', '0', '3', '5'); |
238 case QUIC_VERSION_36: | 230 case QUIC_VERSION_36: |
239 return MakeQuicTag('Q', '0', '3', '6'); | 231 return MakeQuicTag('Q', '0', '3', '6'); |
(...skipping 16 matching lines...) Expand all Loading... |
256 << QuicUtils::TagToString(version_tag); | 248 << QuicUtils::TagToString(version_tag); |
257 return QUIC_VERSION_UNSUPPORTED; | 249 return QUIC_VERSION_UNSUPPORTED; |
258 } | 250 } |
259 | 251 |
260 #define RETURN_STRING_LITERAL(x) \ | 252 #define RETURN_STRING_LITERAL(x) \ |
261 case x: \ | 253 case x: \ |
262 return #x | 254 return #x |
263 | 255 |
264 string QuicVersionToString(const QuicVersion version) { | 256 string QuicVersionToString(const QuicVersion version) { |
265 switch (version) { | 257 switch (version) { |
266 RETURN_STRING_LITERAL(QUIC_VERSION_30); | |
267 RETURN_STRING_LITERAL(QUIC_VERSION_31); | |
268 RETURN_STRING_LITERAL(QUIC_VERSION_32); | 258 RETURN_STRING_LITERAL(QUIC_VERSION_32); |
269 RETURN_STRING_LITERAL(QUIC_VERSION_33); | 259 RETURN_STRING_LITERAL(QUIC_VERSION_33); |
270 RETURN_STRING_LITERAL(QUIC_VERSION_34); | 260 RETURN_STRING_LITERAL(QUIC_VERSION_34); |
271 RETURN_STRING_LITERAL(QUIC_VERSION_35); | 261 RETURN_STRING_LITERAL(QUIC_VERSION_35); |
272 RETURN_STRING_LITERAL(QUIC_VERSION_36); | 262 RETURN_STRING_LITERAL(QUIC_VERSION_36); |
273 default: | 263 default: |
274 return "QUIC_VERSION_UNSUPPORTED"; | 264 return "QUIC_VERSION_UNSUPPORTED"; |
275 } | 265 } |
276 } | 266 } |
277 | 267 |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 | 767 |
778 StringPiece QuicPacket::Plaintext(QuicVersion version) const { | 768 StringPiece QuicPacket::Plaintext(QuicVersion version) const { |
779 const size_t start_of_encrypted_data = GetStartOfEncryptedData( | 769 const size_t start_of_encrypted_data = GetStartOfEncryptedData( |
780 version, connection_id_length_, includes_version_, includes_path_id_, | 770 version, connection_id_length_, includes_version_, includes_path_id_, |
781 includes_diversification_nonce_, packet_number_length_); | 771 includes_diversification_nonce_, packet_number_length_); |
782 return StringPiece(data() + start_of_encrypted_data, | 772 return StringPiece(data() + start_of_encrypted_data, |
783 length() - start_of_encrypted_data); | 773 length() - start_of_encrypted_data); |
784 } | 774 } |
785 | 775 |
786 QuicVersionManager::QuicVersionManager(QuicVersionVector supported_versions) | 776 QuicVersionManager::QuicVersionManager(QuicVersionVector supported_versions) |
787 : disable_pre_32_(FLAGS_quic_disable_pre_32), | 777 : disable_pre_34_(FLAGS_quic_disable_pre_34), |
788 disable_pre_34_(FLAGS_quic_disable_pre_34), | |
789 enable_version_35_(FLAGS_quic_enable_version_35), | 778 enable_version_35_(FLAGS_quic_enable_version_35), |
790 enable_version_36_(FLAGS_quic_enable_version_36_v2), | 779 enable_version_36_(FLAGS_quic_enable_version_36_v2), |
791 allowed_supported_versions_(supported_versions), | 780 allowed_supported_versions_(supported_versions), |
792 filtered_supported_versions_( | 781 filtered_supported_versions_( |
793 FilterSupportedVersions(supported_versions)) {} | 782 FilterSupportedVersions(supported_versions)) {} |
794 | 783 |
795 QuicVersionManager::~QuicVersionManager() {} | 784 QuicVersionManager::~QuicVersionManager() {} |
796 | 785 |
797 const QuicVersionVector& QuicVersionManager::GetSupportedVersions() { | 786 const QuicVersionVector& QuicVersionManager::GetSupportedVersions() { |
798 if (disable_pre_32_ != FLAGS_quic_disable_pre_32 || | 787 if (disable_pre_34_ != FLAGS_quic_disable_pre_34 || |
799 disable_pre_34_ != FLAGS_quic_disable_pre_34 || | |
800 enable_version_35_ != FLAGS_quic_enable_version_35 || | 788 enable_version_35_ != FLAGS_quic_enable_version_35 || |
801 enable_version_36_ != FLAGS_quic_enable_version_36_v2) { | 789 enable_version_36_ != FLAGS_quic_enable_version_36_v2) { |
802 disable_pre_32_ = FLAGS_quic_disable_pre_32; | |
803 disable_pre_34_ = FLAGS_quic_disable_pre_34; | 790 disable_pre_34_ = FLAGS_quic_disable_pre_34; |
804 enable_version_35_ = FLAGS_quic_enable_version_35; | 791 enable_version_35_ = FLAGS_quic_enable_version_35; |
805 enable_version_36_ = FLAGS_quic_enable_version_36_v2; | 792 enable_version_36_ = FLAGS_quic_enable_version_36_v2; |
806 filtered_supported_versions_ = | 793 filtered_supported_versions_ = |
807 FilterSupportedVersions(allowed_supported_versions_); | 794 FilterSupportedVersions(allowed_supported_versions_); |
808 } | 795 } |
809 return filtered_supported_versions_; | 796 return filtered_supported_versions_; |
810 } | 797 } |
811 | 798 |
812 AckListenerWrapper::AckListenerWrapper(QuicAckListenerInterface* listener, | 799 AckListenerWrapper::AckListenerWrapper(QuicAckListenerInterface* listener, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 is_unackable(false), | 862 is_unackable(false), |
876 has_crypto_handshake(has_crypto_handshake), | 863 has_crypto_handshake(has_crypto_handshake), |
877 num_padding_bytes(num_padding_bytes), | 864 num_padding_bytes(num_padding_bytes), |
878 retransmission(0) {} | 865 retransmission(0) {} |
879 | 866 |
880 TransmissionInfo::TransmissionInfo(const TransmissionInfo& other) = default; | 867 TransmissionInfo::TransmissionInfo(const TransmissionInfo& other) = default; |
881 | 868 |
882 TransmissionInfo::~TransmissionInfo() {} | 869 TransmissionInfo::~TransmissionInfo() {} |
883 | 870 |
884 } // namespace net | 871 } // namespace net |
OLD | NEW |