diff --git a/quic/QuicConstants.h b/quic/QuicConstants.h index af02a3bbf..fb5d617cd 100644 --- a/quic/QuicConstants.h +++ b/quic/QuicConstants.h @@ -37,6 +37,7 @@ using SystemClock = folly::chrono::SystemClock; namespace quic { using ByteRange = folly::ByteRange; +using MutableByteRange = folly::MutableByteRange; using BufHelpers = folly::IOBuf; // For stuff like BufHelpers::create, etc. using Buf = folly::IOBuf; // Used when we're not wrapping the buffer in an // std::unique_ptr diff --git a/quic/api/QuicTransportFunctions.cpp b/quic/api/QuicTransportFunctions.cpp index b2bcbfc85..277091b12 100644 --- a/quic/api/QuicTransportFunctions.cpp +++ b/quic/api/QuicTransportFunctions.cpp @@ -1528,8 +1528,8 @@ void encryptPacketHeader( encryptedBody += sampleBytesToUse; memcpy(sample.data(), encryptedBody, sample.size()); - folly::MutableByteRange initialByteRange(header, 1); - folly::MutableByteRange packetNumByteRange( + MutableByteRange initialByteRange(header, 1); + MutableByteRange packetNumByteRange( header + headerLen - packetNumberLength, packetNumberLength); if (headerForm == HeaderForm::Short) { headerCipher.encryptShortHeader( diff --git a/quic/codec/PacketNumberCipher.cpp b/quic/codec/PacketNumberCipher.cpp index af29b0d80..f90eff43a 100644 --- a/quic/codec/PacketNumberCipher.cpp +++ b/quic/codec/PacketNumberCipher.cpp @@ -15,8 +15,8 @@ namespace quic { void PacketNumberCipher::decipherHeader( ByteRange sample, - folly::MutableByteRange initialByte, - folly::MutableByteRange packetNumberBytes, + MutableByteRange initialByte, + MutableByteRange packetNumberBytes, uint8_t initialByteMask, uint8_t /* packetNumLengthMask */) const { CHECK_EQ(packetNumberBytes.size(), kMaxPacketNumEncodingSize); @@ -32,8 +32,8 @@ void PacketNumberCipher::decipherHeader( void PacketNumberCipher::cipherHeader( ByteRange sample, - folly::MutableByteRange initialByte, - folly::MutableByteRange packetNumberBytes, + MutableByteRange initialByte, + MutableByteRange packetNumberBytes, uint8_t initialByteMask, uint8_t /* packetNumLengthMask */) const { HeaderProtectionMask headerMask = mask(sample); @@ -48,8 +48,8 @@ void PacketNumberCipher::cipherHeader( void PacketNumberCipher::decryptLongHeader( ByteRange sample, - folly::MutableByteRange initialByte, - folly::MutableByteRange packetNumberBytes) const { + MutableByteRange initialByte, + MutableByteRange packetNumberBytes) const { decipherHeader( sample, initialByte, @@ -60,8 +60,8 @@ void PacketNumberCipher::decryptLongHeader( void PacketNumberCipher::decryptShortHeader( ByteRange sample, - folly::MutableByteRange initialByte, - folly::MutableByteRange packetNumberBytes) const { + MutableByteRange initialByte, + MutableByteRange packetNumberBytes) const { decipherHeader( sample, initialByte, @@ -72,8 +72,8 @@ void PacketNumberCipher::decryptShortHeader( void PacketNumberCipher::encryptLongHeader( ByteRange sample, - folly::MutableByteRange initialByte, - folly::MutableByteRange packetNumberBytes) const { + MutableByteRange initialByte, + MutableByteRange packetNumberBytes) const { cipherHeader( sample, initialByte, @@ -84,8 +84,8 @@ void PacketNumberCipher::encryptLongHeader( void PacketNumberCipher::encryptShortHeader( ByteRange sample, - folly::MutableByteRange initialByte, - folly::MutableByteRange packetNumberBytes) const { + MutableByteRange initialByte, + MutableByteRange packetNumberBytes) const { cipherHeader( sample, initialByte, diff --git a/quic/codec/PacketNumberCipher.h b/quic/codec/PacketNumberCipher.h index 65c8e36a9..758934f62 100644 --- a/quic/codec/PacketNumberCipher.h +++ b/quic/codec/PacketNumberCipher.h @@ -32,8 +32,8 @@ class PacketNumberCipher { */ virtual void decryptLongHeader( ByteRange sample, - folly::MutableByteRange initialByte, - folly::MutableByteRange packetNumberBytes) const; + MutableByteRange initialByte, + MutableByteRange packetNumberBytes) const; /** * Decrypts a short header from a sample. @@ -43,8 +43,8 @@ class PacketNumberCipher { */ virtual void decryptShortHeader( ByteRange sample, - folly::MutableByteRange initialByte, - folly::MutableByteRange packetNumberBytes) const; + MutableByteRange initialByte, + MutableByteRange packetNumberBytes) const; /** * Encrypts a long header from a sample. @@ -53,8 +53,8 @@ class PacketNumberCipher { */ virtual void encryptLongHeader( ByteRange sample, - folly::MutableByteRange initialByte, - folly::MutableByteRange packetNumberBytes) const; + MutableByteRange initialByte, + MutableByteRange packetNumberBytes) const; /** * Encrypts a short header from a sample. @@ -63,8 +63,8 @@ class PacketNumberCipher { */ virtual void encryptShortHeader( ByteRange sample, - folly::MutableByteRange initialByte, - folly::MutableByteRange packetNumberBytes) const; + MutableByteRange initialByte, + MutableByteRange packetNumberBytes) const; /** * Returns the length of key needed for the pn cipher. @@ -79,15 +79,15 @@ class PacketNumberCipher { protected: virtual void cipherHeader( ByteRange sample, - folly::MutableByteRange initialByte, - folly::MutableByteRange packetNumberBytes, + MutableByteRange initialByte, + MutableByteRange packetNumberBytes, uint8_t initialByteMask, uint8_t packetNumLengthMask) const; virtual void decipherHeader( ByteRange sample, - folly::MutableByteRange initialByte, - folly::MutableByteRange packetNumberBytes, + MutableByteRange initialByte, + MutableByteRange packetNumberBytes, uint8_t initialByteMask, uint8_t packetNumLengthMask) const; }; diff --git a/quic/codec/QuicReadCodec.cpp b/quic/codec/QuicReadCodec.cpp index f8abdbf07..900043bb0 100644 --- a/quic/codec/QuicReadCodec.cpp +++ b/quic/codec/QuicReadCodec.cpp @@ -216,9 +216,8 @@ CodecResult QuicReadCodec::parseLongHeaderPacket( if (largestRecvdPacketNum) { expectedNextPacketNum = 1 + *largestRecvdPacketNum; } - folly::MutableByteRange initialByteRange( - currentPacketData->writableData(), 1); - folly::MutableByteRange packetNumberByteRange( + MutableByteRange initialByteRange(currentPacketData->writableData(), 1); + MutableByteRange packetNumberByteRange( currentPacketData->writableData() + packetNumberOffset, kMaxPacketNumEncodingSize); headerCipher->decryptLongHeader( @@ -287,8 +286,8 @@ CodecResult QuicReadCodec::tryParseShortHeaderPacket( return CodecResult(Nothing()); } - folly::MutableByteRange initialByteRange(data->writableData(), 1); - folly::MutableByteRange packetNumberByteRange( + MutableByteRange initialByteRange(data->writableData(), 1); + MutableByteRange packetNumberByteRange( data->writableData() + packetNumberOffset, kMaxPacketNumEncodingSize); ByteRange sampleByteRange(data->writableData() + sampleOffset, sample.size()); diff --git a/quic/logging/FileQLogger.cpp b/quic/logging/FileQLogger.cpp index d475f4925..ddb6c657f 100644 --- a/quic/logging/FileQLogger.cpp +++ b/quic/logging/FileQLogger.cpp @@ -88,7 +88,7 @@ void FileQLogger::writeToStream(folly::StringPiece message) { while (!inputConsumed) { compressionBuffer_->clear(); ByteRange inputRange(message); - auto outputRange = folly::MutableByteRange( + auto outputRange = MutableByteRange( compressionBuffer_->writableData(), compressionBuffer_->capacity()); compressionCodec_->compressStream(inputRange, outputRange); // Output range has advanced to last compressed byte written @@ -149,7 +149,7 @@ void FileQLogger::finishStream() { while (!ended) { compressionBuffer_->clear(); ByteRange inputRange(folly::StringPiece("")); - auto outputRange = folly::MutableByteRange( + auto outputRange = MutableByteRange( compressionBuffer_->writableData(), compressionBuffer_->capacity()); ended = compressionCodec_->compressStream( inputRange,