mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-08-08 09:42:06 +03:00
Make a MutableByteRange typealias
Summary: See title Differential Revision: D73621432 fbshipit-source-id: fd144f097ca80ffe04aab06c2412eed438de3f5b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
7d4f053bf7
commit
7b7c3eb88f
@@ -37,6 +37,7 @@ using SystemClock = folly::chrono::SystemClock;
|
|||||||
namespace quic {
|
namespace quic {
|
||||||
|
|
||||||
using ByteRange = folly::ByteRange;
|
using ByteRange = folly::ByteRange;
|
||||||
|
using MutableByteRange = folly::MutableByteRange;
|
||||||
using BufHelpers = folly::IOBuf; // For stuff like BufHelpers::create, etc.
|
using BufHelpers = folly::IOBuf; // For stuff like BufHelpers::create, etc.
|
||||||
using Buf = folly::IOBuf; // Used when we're not wrapping the buffer in an
|
using Buf = folly::IOBuf; // Used when we're not wrapping the buffer in an
|
||||||
// std::unique_ptr
|
// std::unique_ptr
|
||||||
|
@@ -1528,8 +1528,8 @@ void encryptPacketHeader(
|
|||||||
encryptedBody += sampleBytesToUse;
|
encryptedBody += sampleBytesToUse;
|
||||||
memcpy(sample.data(), encryptedBody, sample.size());
|
memcpy(sample.data(), encryptedBody, sample.size());
|
||||||
|
|
||||||
folly::MutableByteRange initialByteRange(header, 1);
|
MutableByteRange initialByteRange(header, 1);
|
||||||
folly::MutableByteRange packetNumByteRange(
|
MutableByteRange packetNumByteRange(
|
||||||
header + headerLen - packetNumberLength, packetNumberLength);
|
header + headerLen - packetNumberLength, packetNumberLength);
|
||||||
if (headerForm == HeaderForm::Short) {
|
if (headerForm == HeaderForm::Short) {
|
||||||
headerCipher.encryptShortHeader(
|
headerCipher.encryptShortHeader(
|
||||||
|
@@ -15,8 +15,8 @@ namespace quic {
|
|||||||
|
|
||||||
void PacketNumberCipher::decipherHeader(
|
void PacketNumberCipher::decipherHeader(
|
||||||
ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes,
|
MutableByteRange packetNumberBytes,
|
||||||
uint8_t initialByteMask,
|
uint8_t initialByteMask,
|
||||||
uint8_t /* packetNumLengthMask */) const {
|
uint8_t /* packetNumLengthMask */) const {
|
||||||
CHECK_EQ(packetNumberBytes.size(), kMaxPacketNumEncodingSize);
|
CHECK_EQ(packetNumberBytes.size(), kMaxPacketNumEncodingSize);
|
||||||
@@ -32,8 +32,8 @@ void PacketNumberCipher::decipherHeader(
|
|||||||
|
|
||||||
void PacketNumberCipher::cipherHeader(
|
void PacketNumberCipher::cipherHeader(
|
||||||
ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes,
|
MutableByteRange packetNumberBytes,
|
||||||
uint8_t initialByteMask,
|
uint8_t initialByteMask,
|
||||||
uint8_t /* packetNumLengthMask */) const {
|
uint8_t /* packetNumLengthMask */) const {
|
||||||
HeaderProtectionMask headerMask = mask(sample);
|
HeaderProtectionMask headerMask = mask(sample);
|
||||||
@@ -48,8 +48,8 @@ void PacketNumberCipher::cipherHeader(
|
|||||||
|
|
||||||
void PacketNumberCipher::decryptLongHeader(
|
void PacketNumberCipher::decryptLongHeader(
|
||||||
ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes) const {
|
MutableByteRange packetNumberBytes) const {
|
||||||
decipherHeader(
|
decipherHeader(
|
||||||
sample,
|
sample,
|
||||||
initialByte,
|
initialByte,
|
||||||
@@ -60,8 +60,8 @@ void PacketNumberCipher::decryptLongHeader(
|
|||||||
|
|
||||||
void PacketNumberCipher::decryptShortHeader(
|
void PacketNumberCipher::decryptShortHeader(
|
||||||
ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes) const {
|
MutableByteRange packetNumberBytes) const {
|
||||||
decipherHeader(
|
decipherHeader(
|
||||||
sample,
|
sample,
|
||||||
initialByte,
|
initialByte,
|
||||||
@@ -72,8 +72,8 @@ void PacketNumberCipher::decryptShortHeader(
|
|||||||
|
|
||||||
void PacketNumberCipher::encryptLongHeader(
|
void PacketNumberCipher::encryptLongHeader(
|
||||||
ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes) const {
|
MutableByteRange packetNumberBytes) const {
|
||||||
cipherHeader(
|
cipherHeader(
|
||||||
sample,
|
sample,
|
||||||
initialByte,
|
initialByte,
|
||||||
@@ -84,8 +84,8 @@ void PacketNumberCipher::encryptLongHeader(
|
|||||||
|
|
||||||
void PacketNumberCipher::encryptShortHeader(
|
void PacketNumberCipher::encryptShortHeader(
|
||||||
ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes) const {
|
MutableByteRange packetNumberBytes) const {
|
||||||
cipherHeader(
|
cipherHeader(
|
||||||
sample,
|
sample,
|
||||||
initialByte,
|
initialByte,
|
||||||
|
@@ -32,8 +32,8 @@ class PacketNumberCipher {
|
|||||||
*/
|
*/
|
||||||
virtual void decryptLongHeader(
|
virtual void decryptLongHeader(
|
||||||
ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes) const;
|
MutableByteRange packetNumberBytes) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decrypts a short header from a sample.
|
* Decrypts a short header from a sample.
|
||||||
@@ -43,8 +43,8 @@ class PacketNumberCipher {
|
|||||||
*/
|
*/
|
||||||
virtual void decryptShortHeader(
|
virtual void decryptShortHeader(
|
||||||
ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes) const;
|
MutableByteRange packetNumberBytes) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypts a long header from a sample.
|
* Encrypts a long header from a sample.
|
||||||
@@ -53,8 +53,8 @@ class PacketNumberCipher {
|
|||||||
*/
|
*/
|
||||||
virtual void encryptLongHeader(
|
virtual void encryptLongHeader(
|
||||||
ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes) const;
|
MutableByteRange packetNumberBytes) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypts a short header from a sample.
|
* Encrypts a short header from a sample.
|
||||||
@@ -63,8 +63,8 @@ class PacketNumberCipher {
|
|||||||
*/
|
*/
|
||||||
virtual void encryptShortHeader(
|
virtual void encryptShortHeader(
|
||||||
ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes) const;
|
MutableByteRange packetNumberBytes) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the length of key needed for the pn cipher.
|
* Returns the length of key needed for the pn cipher.
|
||||||
@@ -79,15 +79,15 @@ class PacketNumberCipher {
|
|||||||
protected:
|
protected:
|
||||||
virtual void cipherHeader(
|
virtual void cipherHeader(
|
||||||
ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes,
|
MutableByteRange packetNumberBytes,
|
||||||
uint8_t initialByteMask,
|
uint8_t initialByteMask,
|
||||||
uint8_t packetNumLengthMask) const;
|
uint8_t packetNumLengthMask) const;
|
||||||
|
|
||||||
virtual void decipherHeader(
|
virtual void decipherHeader(
|
||||||
ByteRange sample,
|
ByteRange sample,
|
||||||
folly::MutableByteRange initialByte,
|
MutableByteRange initialByte,
|
||||||
folly::MutableByteRange packetNumberBytes,
|
MutableByteRange packetNumberBytes,
|
||||||
uint8_t initialByteMask,
|
uint8_t initialByteMask,
|
||||||
uint8_t packetNumLengthMask) const;
|
uint8_t packetNumLengthMask) const;
|
||||||
};
|
};
|
||||||
|
@@ -216,9 +216,8 @@ CodecResult QuicReadCodec::parseLongHeaderPacket(
|
|||||||
if (largestRecvdPacketNum) {
|
if (largestRecvdPacketNum) {
|
||||||
expectedNextPacketNum = 1 + *largestRecvdPacketNum;
|
expectedNextPacketNum = 1 + *largestRecvdPacketNum;
|
||||||
}
|
}
|
||||||
folly::MutableByteRange initialByteRange(
|
MutableByteRange initialByteRange(currentPacketData->writableData(), 1);
|
||||||
currentPacketData->writableData(), 1);
|
MutableByteRange packetNumberByteRange(
|
||||||
folly::MutableByteRange packetNumberByteRange(
|
|
||||||
currentPacketData->writableData() + packetNumberOffset,
|
currentPacketData->writableData() + packetNumberOffset,
|
||||||
kMaxPacketNumEncodingSize);
|
kMaxPacketNumEncodingSize);
|
||||||
headerCipher->decryptLongHeader(
|
headerCipher->decryptLongHeader(
|
||||||
@@ -287,8 +286,8 @@ CodecResult QuicReadCodec::tryParseShortHeaderPacket(
|
|||||||
return CodecResult(Nothing());
|
return CodecResult(Nothing());
|
||||||
}
|
}
|
||||||
|
|
||||||
folly::MutableByteRange initialByteRange(data->writableData(), 1);
|
MutableByteRange initialByteRange(data->writableData(), 1);
|
||||||
folly::MutableByteRange packetNumberByteRange(
|
MutableByteRange packetNumberByteRange(
|
||||||
data->writableData() + packetNumberOffset, kMaxPacketNumEncodingSize);
|
data->writableData() + packetNumberOffset, kMaxPacketNumEncodingSize);
|
||||||
ByteRange sampleByteRange(data->writableData() + sampleOffset, sample.size());
|
ByteRange sampleByteRange(data->writableData() + sampleOffset, sample.size());
|
||||||
|
|
||||||
|
@@ -88,7 +88,7 @@ void FileQLogger::writeToStream(folly::StringPiece message) {
|
|||||||
while (!inputConsumed) {
|
while (!inputConsumed) {
|
||||||
compressionBuffer_->clear();
|
compressionBuffer_->clear();
|
||||||
ByteRange inputRange(message);
|
ByteRange inputRange(message);
|
||||||
auto outputRange = folly::MutableByteRange(
|
auto outputRange = MutableByteRange(
|
||||||
compressionBuffer_->writableData(), compressionBuffer_->capacity());
|
compressionBuffer_->writableData(), compressionBuffer_->capacity());
|
||||||
compressionCodec_->compressStream(inputRange, outputRange);
|
compressionCodec_->compressStream(inputRange, outputRange);
|
||||||
// Output range has advanced to last compressed byte written
|
// Output range has advanced to last compressed byte written
|
||||||
@@ -149,7 +149,7 @@ void FileQLogger::finishStream() {
|
|||||||
while (!ended) {
|
while (!ended) {
|
||||||
compressionBuffer_->clear();
|
compressionBuffer_->clear();
|
||||||
ByteRange inputRange(folly::StringPiece(""));
|
ByteRange inputRange(folly::StringPiece(""));
|
||||||
auto outputRange = folly::MutableByteRange(
|
auto outputRange = MutableByteRange(
|
||||||
compressionBuffer_->writableData(), compressionBuffer_->capacity());
|
compressionBuffer_->writableData(), compressionBuffer_->capacity());
|
||||||
ended = compressionCodec_->compressStream(
|
ended = compressionCodec_->compressStream(
|
||||||
inputRange,
|
inputRange,
|
||||||
|
Reference in New Issue
Block a user