| // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef NET_QUIC_QUIC_VERSIONS_H_ |
| #define NET_QUIC_QUIC_VERSIONS_H_ |
| |
| #include <string> |
| #include <vector> |
| |
| #include "net/quic/core/quic_tag.h" |
| #include "net/quic/core/quic_types.h" |
| |
| namespace net { |
| |
| // The available versions of QUIC. Guaranteed that the integer value of the enum |
| // will match the version number. |
| // When adding a new version to this enum you should add it to |
| // kSupportedQuicVersions (if appropriate), and also add a new case to the |
| // helper methods QuicVersionToQuicTag, QuicTagToQuicVersion, and |
| // QuicVersionToString. |
| enum QuicVersion { |
| // Special case to indicate unknown/unsupported QUIC version. |
| QUIC_VERSION_UNSUPPORTED = 0, |
| |
| QUIC_VERSION_34 = 34, // Deprecates entropy, removes private flag from packet |
| // header, uses new ack and stop waiting wire format. |
| QUIC_VERSION_35 = 35, // Allows endpoints to independently set stream limit. |
| QUIC_VERSION_36 = 36, // Add support to force HOL blocking. |
| |
| // IMPORTANT: if you are adding to this std::list, follow the instructions at |
| // http://sites/quic/adding-and-removing-versions |
| }; |
| |
| // This vector contains QUIC versions which we currently support. |
| // This should be ordered such that the highest supported version is the first |
| // element, with subsequent elements in descending order (versions can be |
| // skipped as necessary). |
| // |
| // IMPORTANT: if you are adding to this list, follow the instructions at |
| // http://sites/quic/adding-and-removing-versions |
| static const QuicVersion kSupportedQuicVersions[] = { |
| QUIC_VERSION_36, QUIC_VERSION_35, QUIC_VERSION_34}; |
| |
| typedef std::vector<QuicVersion> QuicVersionVector; |
| |
| // Returns a vector of QUIC versions in kSupportedQuicVersions. |
| NET_EXPORT_PRIVATE QuicVersionVector AllSupportedVersions(); |
| |
| // Returns a vector of QUIC versions from kSupportedQuicVersions which exclude |
| // any versions which are disabled by flags. |
| NET_EXPORT_PRIVATE QuicVersionVector CurrentSupportedVersions(); |
| |
| // Returns a vector of QUIC versions from |versions| which exclude any versions |
| // which are disabled by flags. |
| NET_EXPORT_PRIVATE QuicVersionVector |
| FilterSupportedVersions(QuicVersionVector versions); |
| |
| // Returns QUIC version of |index| in result of |versions|. Returns |
| // QUIC_VERSION_UNSUPPORTED if |index| is out of bounds. |
| NET_EXPORT_PRIVATE QuicVersionVector |
| VersionOfIndex(const QuicVersionVector& versions, int index); |
| |
| // QuicTag is written to and read from the wire, but we prefer to use |
| // the more readable QuicVersion at other levels. |
| // Helper function which translates from a QuicVersion to a QuicTag. Returns 0 |
| // if QuicVersion is unsupported. |
| NET_EXPORT_PRIVATE QuicTag QuicVersionToQuicTag(const QuicVersion version); |
| |
| // Returns appropriate QuicVersion from a QuicTag. |
| // Returns QUIC_VERSION_UNSUPPORTED if version_tag cannot be understood. |
| NET_EXPORT_PRIVATE QuicVersion QuicTagToQuicVersion(const QuicTag version_tag); |
| |
| // Helper function which translates from a QuicVersion to a string. |
| // Returns strings corresponding to enum names (e.g. QUIC_VERSION_6). |
| NET_EXPORT_PRIVATE std::string QuicVersionToString(const QuicVersion version); |
| |
| // Returns comma separated list of string representations of QuicVersion enum |
| // values in the supplied |versions| vector. |
| NET_EXPORT_PRIVATE std::string QuicVersionVectorToString( |
| const QuicVersionVector& versions); |
| |
| } // namespace net |
| |
| #endif // NET_QUIC_QUIC_VERSIONS_H_ |