mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-07-30 14:43:05 +03:00
Change more instances of folly::IOBuf to the typealiases
Summary: See title Differential Revision: D76769545 fbshipit-source-id: 0e4ff49ba34377acec4382b7e9628626f9971984
This commit is contained in:
committed by
Facebook GitHub Bot
parent
3f2bd6f618
commit
8eef42f39b
@ -333,8 +333,7 @@ continuousMemoryBuildScheduleEncrypt(
|
|||||||
packetBuf->prepend(prevSize);
|
packetBuf->prepend(prevSize);
|
||||||
if (connection.transportSettings.isPriming && packetBuf) {
|
if (connection.transportSettings.isPriming && packetBuf) {
|
||||||
packetBuf->coalesce();
|
packetBuf->coalesce();
|
||||||
connection.bufAccessor->release(
|
connection.bufAccessor->release(BufHelpers::create(packetBuf->capacity()));
|
||||||
folly::IOBuf::create(packetBuf->capacity()));
|
|
||||||
connection.primingData_.emplace_back(std::move(packetBuf));
|
connection.primingData_.emplace_back(std::move(packetBuf));
|
||||||
return DataPathResult::makeWriteResult(
|
return DataPathResult::makeWriteResult(
|
||||||
true, std::move(result.value()), encodedSize, encodedBodySize);
|
true, std::move(result.value()), encodedSize, encodedBodySize);
|
||||||
@ -1470,7 +1469,7 @@ void writeCloseCommon(
|
|||||||
bufUniquePtr->data(),
|
bufUniquePtr->data(),
|
||||||
bufUniquePtr->length(),
|
bufUniquePtr->length(),
|
||||||
headerCipher);
|
headerCipher);
|
||||||
folly::IOBuf packetBuf(std::move(packet.header));
|
Buf packetBuf(std::move(packet.header));
|
||||||
packetBuf.appendToChain(std::move(bufUniquePtr));
|
packetBuf.appendToChain(std::move(bufUniquePtr));
|
||||||
auto packetSize = packetBuf.computeChainDataLength();
|
auto packetSize = packetBuf.computeChainDataLength();
|
||||||
if (connection.qLogger) {
|
if (connection.qLogger) {
|
||||||
|
@ -354,7 +354,7 @@ QuicReadCodec::tryParseShortHeaderPacket(
|
|||||||
// don't clone the buffer, the buffer will not show up as shared and we can
|
// don't clone the buffer, the buffer will not show up as shared and we can
|
||||||
// decrypt in-place.
|
// decrypt in-place.
|
||||||
size_t aadLen = packetNumberOffset + packetNum.second;
|
size_t aadLen = packetNumberOffset + packetNum.second;
|
||||||
folly::IOBuf headerData = BufHelpers::wrapBufferAsValue(data->data(), aadLen);
|
Buf headerData = BufHelpers::wrapBufferAsValue(data->data(), aadLen);
|
||||||
data->trimStart(aadLen);
|
data->trimStart(aadLen);
|
||||||
|
|
||||||
BufPtr decrypted;
|
BufPtr decrypted;
|
||||||
|
@ -52,7 +52,7 @@ const RegularQuicWritePacket& writeQuicPacket(
|
|||||||
ConnectionId dstConnId,
|
ConnectionId dstConnId,
|
||||||
quic::test::MockAsyncUDPSocket& sock,
|
quic::test::MockAsyncUDPSocket& sock,
|
||||||
QuicStreamState& stream,
|
QuicStreamState& stream,
|
||||||
const folly::IOBuf& data,
|
const Buf& data,
|
||||||
bool eof = false);
|
bool eof = false);
|
||||||
|
|
||||||
RegularQuicPacketBuilder::Packet createAckPacket(
|
RegularQuicPacketBuilder::Packet createAckPacket(
|
||||||
@ -82,7 +82,7 @@ RegularQuicPacketBuilder::Packet createStreamPacket(
|
|||||||
ConnectionId dstConnId,
|
ConnectionId dstConnId,
|
||||||
PacketNum packetNum,
|
PacketNum packetNum,
|
||||||
StreamId streamId,
|
StreamId streamId,
|
||||||
folly::IOBuf& data,
|
Buf& data,
|
||||||
uint8_t cipherOverhead,
|
uint8_t cipherOverhead,
|
||||||
PacketNum largestAcked,
|
PacketNum largestAcked,
|
||||||
Optional<std::pair<LongHeader::Types, QuicVersion>> longHeaderOverride =
|
Optional<std::pair<LongHeader::Types, QuicVersion>> longHeaderOverride =
|
||||||
@ -169,7 +169,7 @@ std::unique_ptr<T> createNoOpAeadImpl(uint64_t cipherOverhead = 0) {
|
|||||||
if (buf) {
|
if (buf) {
|
||||||
return std::move(buf);
|
return std::move(buf);
|
||||||
} else {
|
} else {
|
||||||
return folly::IOBuf::create(0);
|
return BufHelpers::create(0);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
// Fake that the handshake has already occurred and fix the keys.
|
// Fake that the handshake has already occurred and fix the keys.
|
||||||
@ -248,7 +248,7 @@ OutstandingPacketWrapper* findOutstandingPacket(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to generate a buffer containing random data of given length
|
// Helper function to generate a buffer containing random data of given length
|
||||||
std::unique_ptr<folly::IOBuf> buildRandomInputData(size_t length);
|
BufPtr buildRandomInputData(size_t length);
|
||||||
|
|
||||||
void addAckStatesWithCurrentTimestamps(
|
void addAckStatesWithCurrentTimestamps(
|
||||||
AckState& ackState,
|
AckState& ackState,
|
||||||
@ -336,9 +336,7 @@ void overridePacketWithToken(
|
|||||||
PacketBuilderInterface::Packet& packet,
|
PacketBuilderInterface::Packet& packet,
|
||||||
const StatelessResetToken& token);
|
const StatelessResetToken& token);
|
||||||
|
|
||||||
void overridePacketWithToken(
|
void overridePacketWithToken(Buf& bodyBuf, const StatelessResetToken& token);
|
||||||
folly::IOBuf& bodyBuf,
|
|
||||||
const StatelessResetToken& token);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns if the current writable streams contains the given id.
|
* Returns if the current writable streams contains the given id.
|
||||||
@ -388,7 +386,7 @@ class TestPacketBatchWriter : public IOBufBatchWriter {
|
|||||||
void reset() override;
|
void reset() override;
|
||||||
|
|
||||||
bool append(
|
bool append(
|
||||||
std::unique_ptr<folly::IOBuf>&& /*unused*/,
|
BufPtr&& /*unused*/,
|
||||||
size_t size,
|
size_t size,
|
||||||
const folly::SocketAddress& /*unused*/,
|
const folly::SocketAddress& /*unused*/,
|
||||||
QuicAsyncUDPSocket* /*unused*/) override;
|
QuicAsyncUDPSocket* /*unused*/) override;
|
||||||
@ -407,7 +405,7 @@ class TestPacketBatchWriter : public IOBufBatchWriter {
|
|||||||
size_t bufSize_{0};
|
size_t bufSize_{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<folly::IOBuf> getProtectionKey();
|
BufPtr getProtectionKey();
|
||||||
|
|
||||||
class FakeServerHandshake : public FizzServerHandshake {
|
class FakeServerHandshake : public FizzServerHandshake {
|
||||||
public:
|
public:
|
||||||
@ -439,12 +437,12 @@ class FakeServerHandshake : public FizzServerHandshake {
|
|||||||
// Fall through and let the ServerStateMachine to process the event
|
// Fall through and let the ServerStateMachine to process the event
|
||||||
writeDataToQuicStream(
|
writeDataToQuicStream(
|
||||||
*getCryptoStream(*conn_.cryptoState, EncryptionLevel::Initial),
|
*getCryptoStream(*conn_.cryptoState, EncryptionLevel::Initial),
|
||||||
folly::IOBuf::copyBuffer("SHLO"));
|
BufHelpers::copyBuffer("SHLO"));
|
||||||
if (chloWithCert) {
|
if (chloWithCert) {
|
||||||
/* write 4000 bytes of data to the handshake crypto stream */
|
/* write 4000 bytes of data to the handshake crypto stream */
|
||||||
writeDataToQuicStream(
|
writeDataToQuicStream(
|
||||||
*getCryptoStream(*conn_.cryptoState, EncryptionLevel::Handshake),
|
*getCryptoStream(*conn_.cryptoState, EncryptionLevel::Handshake),
|
||||||
folly::IOBuf::copyBuffer(std::string(4000, '.')));
|
BufHelpers::copyBuffer(std::string(4000, '.')));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allowZeroRttKeys_) {
|
if (allowZeroRttKeys_) {
|
||||||
@ -464,12 +462,12 @@ class FakeServerHandshake : public FizzServerHandshake {
|
|||||||
}
|
}
|
||||||
|
|
||||||
folly::Expected<folly::Unit, QuicError> doHandshake(
|
folly::Expected<folly::Unit, QuicError> doHandshake(
|
||||||
std::unique_ptr<folly::IOBuf> data,
|
BufPtr data,
|
||||||
EncryptionLevel) override {
|
EncryptionLevel) override {
|
||||||
folly::IOBufEqualTo eq;
|
folly::IOBufEqualTo eq;
|
||||||
auto chlo = folly::IOBuf::copyBuffer("CHLO");
|
auto chlo = BufHelpers::copyBuffer("CHLO");
|
||||||
auto chloWithCert = folly::IOBuf::copyBuffer("CHLO_CERT");
|
auto chloWithCert = BufHelpers::copyBuffer("CHLO_CERT");
|
||||||
auto clientFinished = folly::IOBuf::copyBuffer("FINISHED");
|
auto clientFinished = BufHelpers::copyBuffer("FINISHED");
|
||||||
bool sendHandshakeBytes = false;
|
bool sendHandshakeBytes = false;
|
||||||
|
|
||||||
if (eq(data, chlo) || (sendHandshakeBytes = eq(data, chloWithCert))) {
|
if (eq(data, chlo) || (sendHandshakeBytes = eq(data, chloWithCert))) {
|
||||||
@ -605,8 +603,8 @@ class FakeServerHandshake : public FizzServerHandshake {
|
|||||||
CHECK(!oneRttReadHeaderCipherResult.hasError())
|
CHECK(!oneRttReadHeaderCipherResult.hasError())
|
||||||
<< "Failed to create header cipher";
|
<< "Failed to create header cipher";
|
||||||
oneRttReadHeaderCipher_ = std::move(oneRttReadHeaderCipherResult.value());
|
oneRttReadHeaderCipher_ = std::move(oneRttReadHeaderCipherResult.value());
|
||||||
readTrafficSecret_ = folly::IOBuf::copyBuffer(getRandSecret());
|
readTrafficSecret_ = BufHelpers::copyBuffer(getRandSecret());
|
||||||
writeTrafficSecret_ = folly::IOBuf::copyBuffer(getRandSecret());
|
writeTrafficSecret_ = BufHelpers::copyBuffer(getRandSecret());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Aead> buildAead(ByteRange /*secret*/) override {
|
std::unique_ptr<Aead> buildAead(ByteRange /*secret*/) override {
|
||||||
@ -614,7 +612,7 @@ class FakeServerHandshake : public FizzServerHandshake {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BufPtr getNextTrafficSecret(ByteRange /*secret*/) const override {
|
BufPtr getNextTrafficSecret(ByteRange /*secret*/) const override {
|
||||||
return folly::IOBuf::copyBuffer(getRandSecret());
|
return BufHelpers::copyBuffer(getRandSecret());
|
||||||
}
|
}
|
||||||
|
|
||||||
void setHandshakeKeys() {
|
void setHandshakeKeys() {
|
||||||
|
@ -168,7 +168,7 @@ folly::Expected<bool, QuicError> FizzClientHandshake::verifyRetryIntegrityTag(
|
|||||||
auto expectedIntegrityTag = retryIntegrityTagGenerator.getRetryIntegrityTag(
|
auto expectedIntegrityTag = retryIntegrityTagGenerator.getRetryIntegrityTag(
|
||||||
retryPacket.header.getVersion(), pseudoRetryPacket.get());
|
retryPacket.header.getVersion(), pseudoRetryPacket.get());
|
||||||
|
|
||||||
folly::IOBuf integrityTagWrapper = BufHelpers::wrapBufferAsValue(
|
Buf integrityTagWrapper = BufHelpers::wrapBufferAsValue(
|
||||||
retryPacket.integrityTag.data(), retryPacket.integrityTag.size());
|
retryPacket.integrityTag.data(), retryPacket.integrityTag.size());
|
||||||
return BufEq()(*expectedIntegrityTag, integrityTagWrapper);
|
return BufEq()(*expectedIntegrityTag, integrityTagWrapper);
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
|
@ -29,7 +29,7 @@ inline quic::BufPtr encodeVarintParams(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// callers expect empty buf if no parameters supplied
|
// callers expect empty buf if no parameters supplied
|
||||||
return folly::IOBuf::create(0);
|
return quic::BufHelpers::create(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fizz::ExtensionType getQuicTransportParametersExtention(
|
inline fizz::ExtensionType getQuicTransportParametersExtention(
|
||||||
|
@ -140,7 +140,7 @@ class FileQLogger : public BaseQLogger {
|
|||||||
|
|
||||||
std::unique_ptr<folly::AsyncFileWriter> writer_;
|
std::unique_ptr<folly::AsyncFileWriter> writer_;
|
||||||
std::unique_ptr<folly::compression::StreamCodec> compressionCodec_;
|
std::unique_ptr<folly::compression::StreamCodec> compressionCodec_;
|
||||||
std::unique_ptr<folly::IOBuf> compressionBuffer_;
|
BufPtr compressionBuffer_;
|
||||||
|
|
||||||
std::string path_;
|
std::string path_;
|
||||||
std::string basePadding_ = " ";
|
std::string basePadding_ = " ";
|
||||||
|
@ -606,7 +606,7 @@ void QuicServerWorker::eventRecvmsgCallback(MsgHdr* msgHdr, int bytesRead) {
|
|||||||
|
|
||||||
bool QuicServerWorker::tryHandlingAsHealthCheck(
|
bool QuicServerWorker::tryHandlingAsHealthCheck(
|
||||||
const folly::SocketAddress& client,
|
const folly::SocketAddress& client,
|
||||||
const folly::IOBuf& data) {
|
const Buf& data) {
|
||||||
// If we cannot parse the long header then it is not a QUIC invariant
|
// If we cannot parse the long header then it is not a QUIC invariant
|
||||||
// packet, so just drop it after checking whether it could be a health
|
// packet, so just drop it after checking whether it could be a health
|
||||||
// check.
|
// check.
|
||||||
|
@ -462,7 +462,7 @@ class QuicServerWorker : public FollyAsyncUDPSocketAlias::ReadCallback,
|
|||||||
*/
|
*/
|
||||||
bool tryHandlingAsHealthCheck(
|
bool tryHandlingAsHealthCheck(
|
||||||
const folly::SocketAddress& client,
|
const folly::SocketAddress& client,
|
||||||
const folly::IOBuf& data);
|
const Buf& data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return Infocallback ptr for various transport stats (such as packet
|
* Return Infocallback ptr for various transport stats (such as packet
|
||||||
|
@ -96,7 +96,7 @@ void writeDataToQuicStream(QuicCryptoStream& stream, BufPtr data) {
|
|||||||
// a logic IOBuf chain, buf. The function will pack data into the available
|
// a logic IOBuf chain, buf. The function will pack data into the available
|
||||||
// tail agressively, and allocate in terms of appendLen until the push is
|
// tail agressively, and allocate in terms of appendLen until the push is
|
||||||
// complete.
|
// complete.
|
||||||
static void pushToTail(folly::IOBuf* dst, BufPtr src, size_t allocSize) {
|
static void pushToTail(Buf* dst, BufPtr src, size_t allocSize) {
|
||||||
size_t appended = 0;
|
size_t appended = 0;
|
||||||
auto len = src->length();
|
auto len = src->length();
|
||||||
auto data = src->data();
|
auto data = src->data();
|
||||||
@ -340,7 +340,7 @@ std::pair<BufPtr, bool> readDataInOrderFromReadBuffer(
|
|||||||
|
|
||||||
uint64_t toRead =
|
uint64_t toRead =
|
||||||
std::min<uint64_t>(currSize, amount == 0 ? currSize : remaining);
|
std::min<uint64_t>(currSize, amount == 0 ? currSize : remaining);
|
||||||
std::unique_ptr<folly::IOBuf> splice;
|
BufPtr splice;
|
||||||
if (sinkData) {
|
if (sinkData) {
|
||||||
curr->data.trimStart(toRead);
|
curr->data.trimStart(toRead);
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user