| Index: net/quic/quic_framer.cc
|
| diff --git a/net/quic/quic_framer.cc b/net/quic/quic_framer.cc
|
| index 1df3590585027850c8652c008a43bc09dcaba7f1..7dfd5432628a99330ef22303a7cec2076a31756b 100644
|
| --- a/net/quic/quic_framer.cc
|
| +++ b/net/quic/quic_framer.cc
|
| @@ -53,7 +53,7 @@ QuicPacketSequenceNumber ClosestTo(QuicPacketSequenceNumber target,
|
|
|
| } // namespace
|
|
|
| -QuicFramer::QuicFramer(QuicTag version,
|
| +QuicFramer::QuicFramer(QuicVersion version,
|
| QuicTime creation_time,
|
| bool is_server)
|
| : visitor_(NULL),
|
| @@ -142,8 +142,13 @@ size_t QuicFramer::GetStreamOffsetSize(QuicStreamOffset offset) {
|
| return 8;
|
| }
|
|
|
| -bool QuicFramer::IsSupportedVersion(QuicTag version) {
|
| - return version == kQuicVersion1;
|
| +bool QuicFramer::IsSupportedVersion(const QuicVersion version) const {
|
| + for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) {
|
| + if (version == kSupportedQuicVersions[i]) {
|
| + return true;
|
| + }
|
| + }
|
| + return false;
|
| }
|
|
|
| size_t QuicFramer::GetVersionNegotiationPacketSize(size_t number_versions) {
|
| @@ -342,7 +347,7 @@ QuicEncryptedPacket* QuicFramer::ConstructPublicResetPacket(
|
|
|
| QuicEncryptedPacket* QuicFramer::ConstructVersionNegotiationPacket(
|
| const QuicPacketPublicHeader& header,
|
| - const QuicTagVector& supported_versions) {
|
| + const QuicVersionVector& supported_versions) {
|
| DCHECK(header.version_flag);
|
| size_t len = GetVersionNegotiationPacketSize(supported_versions.size());
|
| QuicDataWriter writer(len);
|
| @@ -359,7 +364,7 @@ QuicEncryptedPacket* QuicFramer::ConstructVersionNegotiationPacket(
|
| }
|
|
|
| for (size_t i = 0; i < supported_versions.size(); ++i) {
|
| - if (!writer.WriteUInt32(supported_versions[i])) {
|
| + if (!writer.WriteUInt32(QuicVersionToQuicTag(supported_versions[i]))) {
|
| return NULL;
|
| }
|
| }
|
| @@ -413,7 +418,7 @@ bool QuicFramer::ProcessVersionNegotiationPacket(
|
| set_detailed_error("Unable to read supported version in negotiation.");
|
| return RaiseError(QUIC_INVALID_VERSION_NEGOTIATION_PACKET);
|
| }
|
| - public_header->versions.push_back(version);
|
| + public_header->versions.push_back(QuicTagToQuicVersion(version));
|
| } while (!reader_->IsDoneReading());
|
|
|
| visitor_->OnVersionNegotiationPacket(*public_header);
|
| @@ -568,7 +573,7 @@ bool QuicFramer::WritePacketHeader(const QuicPacketHeader& header,
|
|
|
| if (header.public_header.version_flag) {
|
| DCHECK(!is_server_);
|
| - writer->WriteUInt32(quic_version_);
|
| + writer->WriteUInt32(QuicVersionToQuicTag(quic_version_));
|
| }
|
|
|
| if (!AppendPacketSequenceNumber(header.public_header.sequence_number_length,
|
| @@ -713,13 +718,14 @@ bool QuicFramer::ProcessPublicHeader(
|
| }
|
|
|
| if (public_header->version_flag && is_server_) {
|
| - QuicTag version;
|
| - if (!reader_->ReadUInt32(&version)) {
|
| + QuicTag version_tag;
|
| + if (!reader_->ReadUInt32(&version_tag)) {
|
| // Read the version only if the packet is from the client.
|
| // version flag from the server means version negotiation packet.
|
| set_detailed_error("Unable to read protocol version.");
|
| return false;
|
| }
|
| + QuicVersion version = QuicTagToQuicVersion(version_tag);
|
| if (version == quic_version_ && public_flags > PACKET_PUBLIC_FLAGS_MAX) {
|
| set_detailed_error("Illegal public flags value.");
|
| return false;
|
|
|