1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-07-30 14:43:05 +03:00

Introduce a Cursor typealias

Summary: See title

Reviewed By: kvtsoy

Differential Revision: D73474979

fbshipit-source-id: 7048d75e79e619917b226bfc2b90bcd2248e44eb
This commit is contained in:
Aman Sharma
2025-04-23 10:07:20 -07:00
committed by Facebook GitHub Bot
parent 302b9599cf
commit a934b46f49
30 changed files with 193 additions and 202 deletions

View File

@ -8,6 +8,7 @@
#pragma once
#include <folly/chrono/Clock.h>
#include <folly/io/Cursor.h>
#include <folly/io/IOBuf.h>
#include <quic/common/third-party/enum.h>
#include <sys/types.h>
@ -41,6 +42,7 @@ using Buf = folly::IOBuf; // Used when we're not wrapping the buffer in an
// std::unique_ptr
using BufPtr = std::unique_ptr<Buf>;
using BufEq = folly::IOBufEqualTo;
using Cursor = folly::io::Cursor;
using Clock = std::chrono::steady_clock;
using TimePoint = std::chrono::time_point<Clock>;
using DurationRep = std::chrono::microseconds::rep;

View File

@ -369,7 +369,7 @@ void QuicStreamAsyncTransport::handleRead() {
readCb_->readBufferAvailable(std::move(readData->first));
} else {
size_t readLen = readData->first->computeChainDataLength();
folly::io::Cursor c(readData->first.get());
Cursor c(readData->first.get());
CHECK_NOTNULL(buf);
c.pull(buf, readLen);
readCb_->readDataAvailable(readLen);

View File

@ -398,7 +398,7 @@ iobufChainBasedBuildScheduleEncrypt(
auto bodyLen = packet->body.computeChainDataLength();
auto unencrypted = BufHelpers::createCombined(
headerLen + bodyLen + aead.getCipherOverhead());
auto bodyCursor = folly::io::Cursor(&packet->body);
auto bodyCursor = Cursor(&packet->body);
bodyCursor.pull(unencrypted->writableData() + headerLen, bodyLen);
unencrypted->advance(headerLen);
unencrypted->append(bodyLen);
@ -406,7 +406,7 @@ iobufChainBasedBuildScheduleEncrypt(
aead.inplaceEncrypt(std::move(unencrypted), &packet->header, packetNum);
DCHECK(packetBuf->headroom() == headerLen);
packetBuf->clear();
auto headerCursor = folly::io::Cursor(&packet->header);
auto headerCursor = Cursor(&packet->header);
headerCursor.pull(packetBuf->writableData(), headerLen);
packetBuf->append(headerLen + bodyLen + aead.getCipherOverhead());

View File

@ -104,14 +104,14 @@ BufPtr encodeDatagramFrame(BufQueue data) {
return buf;
}
std::pair<BufPtr, uint32_t> decodeDatagramFrame(folly::io::Cursor& cursor) {
std::pair<BufPtr, uint32_t> decodeDatagramFrame(Cursor& cursor) {
BufPtr outData;
auto len = cursor.readBE<uint32_t>();
cursor.clone(outData, len);
return std::make_pair(std::move(outData), len);
}
std::pair<BufPtr, uint64_t> decodeDataBuffer(folly::io::Cursor& cursor) {
std::pair<BufPtr, uint64_t> decodeDataBuffer(Cursor& cursor) {
BufPtr outData;
auto len = cursor.readBE<uint32_t>();
cursor.clone(outData, len);
@ -119,8 +119,7 @@ std::pair<BufPtr, uint64_t> decodeDataBuffer(folly::io::Cursor& cursor) {
return std::make_pair(std::move(outData), offset);
}
std::pair<StreamId, StreamBuffer> decodeStreamBuffer(
folly::io::Cursor& cursor) {
std::pair<StreamId, StreamBuffer> decodeStreamBuffer(Cursor& cursor) {
auto streamId = cursor.readBE<StreamId>();
auto dataBuffer = decodeDataBuffer(cursor);
bool eof = (bool)cursor.readBE<uint8_t>();
@ -135,7 +134,7 @@ struct StreamGroupIdBuf {
StreamBuffer buf;
};
StreamGroupIdBuf decodeStreamGroupBuffer(folly::io::Cursor& cursor) {
StreamGroupIdBuf decodeStreamGroupBuffer(Cursor& cursor) {
auto streamId = cursor.readBE<StreamId>();
auto groupId = cursor.readBE<StreamGroupId>();
auto dataBuffer = decodeDataBuffer(cursor);
@ -146,12 +145,12 @@ StreamGroupIdBuf decodeStreamGroupBuffer(folly::io::Cursor& cursor) {
StreamBuffer(std::move(dataBuffer.first), dataBuffer.second, eof)};
}
StreamBuffer decodeCryptoBuffer(folly::io::Cursor& cursor) {
StreamBuffer decodeCryptoBuffer(Cursor& cursor) {
auto dataBuffer = decodeDataBuffer(cursor);
return StreamBuffer(std::move(dataBuffer.first), dataBuffer.second, false);
}
MaxStreamsFrame decodeMaxStreamsFrame(folly::io::Cursor& cursor) {
MaxStreamsFrame decodeMaxStreamsFrame(Cursor& cursor) {
bool isBidi = cursor.readBE<uint8_t>();
auto maxStreams = cursor.readBE<uint64_t>();
return MaxStreamsFrame(maxStreams, isBidi);
@ -291,7 +290,7 @@ class TestQuicTransport
if (udpPacket.buf.empty()) {
return folly::unit;
}
folly::io::Cursor cursor(udpPacket.buf.front());
Cursor cursor(udpPacket.buf.front());
while (!cursor.isAtEnd()) {
// create server chosen connId with processId = 0 and workerId = 0
ServerConnectionIdParams params(0, 0, 0);

View File

@ -44,8 +44,7 @@ folly::Expected<quic::PacketNum, quic::QuicError> nextAckedPacketLen(
namespace quic {
folly::Expected<PaddingFrame, QuicError> decodePaddingFrame(
folly::io::Cursor& cursor) {
folly::Expected<PaddingFrame, QuicError> decodePaddingFrame(Cursor& cursor) {
// we might have multiple padding frames in sequence in the common case.
// Let's consume all the padding and return 1 padding frame for everything.
static_assert(
@ -68,12 +67,11 @@ folly::Expected<PaddingFrame, QuicError> decodePaddingFrame(
return PaddingFrame();
}
folly::Expected<PingFrame, QuicError> decodePingFrame(folly::io::Cursor&) {
folly::Expected<PingFrame, QuicError> decodePingFrame(Cursor&) {
return PingFrame();
}
folly::Expected<QuicFrame, QuicError> decodeKnobFrame(
folly::io::Cursor& cursor) {
folly::Expected<QuicFrame, QuicError> decodeKnobFrame(Cursor& cursor) {
auto knobSpace = decodeQuicInteger(cursor);
if (!knobSpace) {
return folly::makeUnexpected(QuicError(
@ -96,7 +94,7 @@ folly::Expected<QuicFrame, QuicError> decodeKnobFrame(
}
folly::Expected<QuicSimpleFrame, QuicError> decodeAckFrequencyFrame(
folly::io::Cursor& cursor) {
Cursor& cursor) {
auto sequenceNumber = decodeQuicInteger(cursor);
if (!sequenceNumber) {
return folly::makeUnexpected(QuicError(
@ -129,8 +127,7 @@ folly::Expected<QuicSimpleFrame, QuicError> decodeAckFrequencyFrame(
return QuicSimpleFrame(frame);
}
folly::Expected<ImmediateAckFrame, QuicError> decodeImmediateAckFrame(
folly::io::Cursor&) {
folly::Expected<ImmediateAckFrame, QuicError> decodeImmediateAckFrame(Cursor&) {
return ImmediateAckFrame();
}
@ -162,7 +159,7 @@ folly::Expected<uint64_t, QuicError> convertEncodedDurationToMicroseconds(
}
folly::Expected<ReadAckFrame, QuicError> decodeAckFrame(
folly::io::Cursor& cursor,
Cursor& cursor,
const PacketHeader& header,
const CodecParameters& params,
FrameType frameType) {
@ -252,7 +249,7 @@ folly::Expected<ReadAckFrame, QuicError> decodeAckFrame(
static folly::Expected<folly::Unit, QuicError> decodeReceiveTimestampsInAck(
ReadAckFrame& frame,
folly::io::Cursor& cursor,
Cursor& cursor,
const CodecParameters& params) {
auto latestRecvdPacketNum = decodeQuicInteger(cursor);
if (!latestRecvdPacketNum) {
@ -322,7 +319,7 @@ static folly::Expected<folly::Unit, QuicError> decodeReceiveTimestampsInAck(
static folly::Expected<folly::Unit, QuicError> decodeEcnCountsInAck(
ReadAckFrame& frame,
folly::io::Cursor& cursor) {
Cursor& cursor) {
auto ect_0 = decodeQuicInteger(cursor);
auto ect_1 = decodeQuicInteger(cursor);
auto ce = decodeQuicInteger(cursor);
@ -337,7 +334,7 @@ static folly::Expected<folly::Unit, QuicError> decodeEcnCountsInAck(
}
folly::Expected<ReadAckFrame, QuicError> decodeAckExtendedFrame(
folly::io::Cursor& cursor,
Cursor& cursor,
const PacketHeader& header,
const CodecParameters& params) {
ReadAckFrame frame;
@ -379,7 +376,7 @@ folly::Expected<ReadAckFrame, QuicError> decodeAckExtendedFrame(
}
folly::Expected<QuicFrame, QuicError> decodeAckFrameWithReceivedTimestamps(
folly::io::Cursor& cursor,
Cursor& cursor,
const PacketHeader& header,
const CodecParameters& params,
FrameType frameType) {
@ -401,7 +398,7 @@ folly::Expected<QuicFrame, QuicError> decodeAckFrameWithReceivedTimestamps(
}
folly::Expected<QuicFrame, QuicError> decodeAckFrameWithECN(
folly::io::Cursor& cursor,
Cursor& cursor,
const PacketHeader& header,
const CodecParameters& params) {
ReadAckFrame readAckFrame;
@ -422,7 +419,7 @@ folly::Expected<QuicFrame, QuicError> decodeAckFrameWithECN(
}
folly::Expected<RstStreamFrame, QuicError> decodeRstStreamFrame(
folly::io::Cursor& cursor,
Cursor& cursor,
bool reliable) {
auto streamId = decodeQuicInteger(cursor);
if (!streamId) {
@ -467,7 +464,7 @@ folly::Expected<RstStreamFrame, QuicError> decodeRstStreamFrame(
}
folly::Expected<StopSendingFrame, QuicError> decodeStopSendingFrame(
folly::io::Cursor& cursor) {
Cursor& cursor) {
auto streamId = decodeQuicInteger(cursor);
if (!streamId) {
return folly::makeUnexpected(QuicError(
@ -485,8 +482,7 @@ folly::Expected<StopSendingFrame, QuicError> decodeStopSendingFrame(
return StopSendingFrame(folly::to<StreamId>(streamId->first), errorCode);
}
folly::Expected<ReadCryptoFrame, QuicError> decodeCryptoFrame(
folly::io::Cursor& cursor) {
folly::Expected<ReadCryptoFrame, QuicError> decodeCryptoFrame(Cursor& cursor) {
auto optionalOffset = decodeQuicInteger(cursor);
if (!optionalOffset) {
return folly::makeUnexpected(QuicError(
@ -516,7 +512,7 @@ folly::Expected<ReadCryptoFrame, QuicError> decodeCryptoFrame(
}
folly::Expected<ReadNewTokenFrame, QuicError> decodeNewTokenFrame(
folly::io::Cursor& cursor) {
Cursor& cursor) {
auto tokenLength = decodeQuicInteger(cursor);
if (!tokenLength) {
return folly::makeUnexpected(QuicError(
@ -542,7 +538,7 @@ folly::Expected<ReadStreamFrame, QuicError> decodeStreamFrame(
BufQueue& queue,
StreamTypeField frameTypeField,
bool isGroupFrame) {
folly::io::Cursor cursor(queue.front());
Cursor cursor(queue.front());
auto streamId = decodeQuicInteger(cursor);
if (!streamId) {
@ -621,8 +617,7 @@ folly::Expected<ReadStreamFrame, QuicError> decodeStreamFrame(
groupId);
}
folly::Expected<MaxDataFrame, QuicError> decodeMaxDataFrame(
folly::io::Cursor& cursor) {
folly::Expected<MaxDataFrame, QuicError> decodeMaxDataFrame(Cursor& cursor) {
auto maximumData = decodeQuicInteger(cursor);
if (!maximumData) {
return folly::makeUnexpected(QuicError(
@ -632,7 +627,7 @@ folly::Expected<MaxDataFrame, QuicError> decodeMaxDataFrame(
}
folly::Expected<MaxStreamDataFrame, QuicError> decodeMaxStreamDataFrame(
folly::io::Cursor& cursor) {
Cursor& cursor) {
auto streamId = decodeQuicInteger(cursor);
if (!streamId) {
return folly::makeUnexpected(QuicError(
@ -648,7 +643,7 @@ folly::Expected<MaxStreamDataFrame, QuicError> decodeMaxStreamDataFrame(
}
folly::Expected<MaxStreamsFrame, QuicError> decodeBiDiMaxStreamsFrame(
folly::io::Cursor& cursor) {
Cursor& cursor) {
auto streamCount = decodeQuicInteger(cursor);
if (!streamCount || streamCount->first > kMaxMaxStreams) {
return folly::makeUnexpected(QuicError(
@ -659,7 +654,7 @@ folly::Expected<MaxStreamsFrame, QuicError> decodeBiDiMaxStreamsFrame(
}
folly::Expected<MaxStreamsFrame, QuicError> decodeUniMaxStreamsFrame(
folly::io::Cursor& cursor) {
Cursor& cursor) {
auto streamCount = decodeQuicInteger(cursor);
if (!streamCount || streamCount->first > kMaxMaxStreams) {
return folly::makeUnexpected(QuicError(
@ -670,7 +665,7 @@ folly::Expected<MaxStreamsFrame, QuicError> decodeUniMaxStreamsFrame(
}
folly::Expected<DataBlockedFrame, QuicError> decodeDataBlockedFrame(
folly::io::Cursor& cursor) {
Cursor& cursor) {
auto dataLimit = decodeQuicInteger(cursor);
if (!dataLimit) {
return folly::makeUnexpected(QuicError(
@ -680,7 +675,7 @@ folly::Expected<DataBlockedFrame, QuicError> decodeDataBlockedFrame(
}
folly::Expected<StreamDataBlockedFrame, QuicError> decodeStreamDataBlockedFrame(
folly::io::Cursor& cursor) {
Cursor& cursor) {
auto streamId = decodeQuicInteger(cursor);
if (!streamId) {
return folly::makeUnexpected(QuicError(
@ -696,7 +691,7 @@ folly::Expected<StreamDataBlockedFrame, QuicError> decodeStreamDataBlockedFrame(
}
folly::Expected<StreamsBlockedFrame, QuicError> decodeBiDiStreamsBlockedFrame(
folly::io::Cursor& cursor) {
Cursor& cursor) {
auto streamId = decodeQuicInteger(cursor);
if (!streamId) {
return folly::makeUnexpected(QuicError(
@ -708,7 +703,7 @@ folly::Expected<StreamsBlockedFrame, QuicError> decodeBiDiStreamsBlockedFrame(
}
folly::Expected<StreamsBlockedFrame, QuicError> decodeUniStreamsBlockedFrame(
folly::io::Cursor& cursor) {
Cursor& cursor) {
auto streamId = decodeQuicInteger(cursor);
if (!streamId) {
return folly::makeUnexpected(QuicError(
@ -720,7 +715,7 @@ folly::Expected<StreamsBlockedFrame, QuicError> decodeUniStreamsBlockedFrame(
}
folly::Expected<NewConnectionIdFrame, QuicError> decodeNewConnectionIdFrame(
folly::io::Cursor& cursor) {
Cursor& cursor) {
auto sequenceNumber = decodeQuicInteger(cursor);
if (!sequenceNumber) {
return folly::makeUnexpected(QuicError(
@ -766,7 +761,7 @@ folly::Expected<NewConnectionIdFrame, QuicError> decodeNewConnectionIdFrame(
}
folly::Expected<RetireConnectionIdFrame, QuicError>
decodeRetireConnectionIdFrame(folly::io::Cursor& cursor) {
decodeRetireConnectionIdFrame(Cursor& cursor) {
auto sequenceNum = decodeQuicInteger(cursor);
if (!sequenceNum) {
return folly::makeUnexpected(QuicError(
@ -776,7 +771,7 @@ decodeRetireConnectionIdFrame(folly::io::Cursor& cursor) {
}
folly::Expected<PathChallengeFrame, QuicError> decodePathChallengeFrame(
folly::io::Cursor& cursor) {
Cursor& cursor) {
if (!cursor.canAdvance(sizeof(uint64_t))) {
return folly::makeUnexpected(QuicError(
quic::TransportErrorCode::FRAME_ENCODING_ERROR,
@ -787,7 +782,7 @@ folly::Expected<PathChallengeFrame, QuicError> decodePathChallengeFrame(
}
folly::Expected<PathResponseFrame, QuicError> decodePathResponseFrame(
folly::io::Cursor& cursor) {
Cursor& cursor) {
if (!cursor.canAdvance(sizeof(uint64_t))) {
return folly::makeUnexpected(QuicError(
quic::TransportErrorCode::FRAME_ENCODING_ERROR,
@ -798,7 +793,7 @@ folly::Expected<PathResponseFrame, QuicError> decodePathResponseFrame(
}
folly::Expected<ConnectionCloseFrame, QuicError> decodeConnectionCloseFrame(
folly::io::Cursor& cursor) {
Cursor& cursor) {
TransportErrorCode errorCode{};
auto varCode = decodeQuicInteger(cursor);
if (!varCode) {
@ -836,7 +831,7 @@ folly::Expected<ConnectionCloseFrame, QuicError> decodeConnectionCloseFrame(
}
folly::Expected<ConnectionCloseFrame, QuicError> decodeApplicationClose(
folly::io::Cursor& cursor) {
Cursor& cursor) {
ApplicationErrorCode errorCode{};
auto varCode = decodeQuicInteger(cursor);
if (!varCode) {
@ -866,7 +861,7 @@ folly::Expected<ConnectionCloseFrame, QuicError> decodeApplicationClose(
}
folly::Expected<HandshakeDoneFrame, QuicError> decodeHandshakeDoneFrame(
folly::io::Cursor& /*cursor*/) {
Cursor& /*cursor*/) {
return HandshakeDoneFrame();
}
@ -876,7 +871,7 @@ folly::Expected<HandshakeDoneFrame, QuicError> decodeHandshakeDoneFrame(
* associated data.
*/
folly::Expected<uint64_t, TransportErrorCode> parsePlaintextRetryOrNewToken(
folly::io::Cursor& cursor) {
Cursor& cursor) {
// Read in the timestamp
if (!cursor.canAdvance(sizeof(uint64_t))) {
return folly::makeUnexpected(TransportErrorCode::INVALID_TOKEN);
@ -889,7 +884,7 @@ folly::Expected<uint64_t, TransportErrorCode> parsePlaintextRetryOrNewToken(
folly::Expected<DatagramFrame, QuicError> decodeDatagramFrame(
BufQueue& queue,
bool hasLen) {
folly::io::Cursor cursor(queue.front());
Cursor cursor(queue.front());
size_t length = cursor.length();
if (hasLen) {
auto decodeLength = decodeQuicInteger(cursor);
@ -911,7 +906,7 @@ folly::Expected<QuicFrame, QuicError> parseFrame(
BufQueue& queue,
const PacketHeader& header,
const CodecParameters& params) {
folly::io::Cursor cursor(queue.front());
Cursor cursor(queue.front());
auto frameTypeInt = decodeQuicInteger(cursor);
if (!frameTypeInt) {
return folly::makeUnexpected(QuicError(
@ -1238,7 +1233,7 @@ folly::Expected<RegularQuicPacket, QuicError> decodeRegularPacket(
Optional<VersionNegotiationPacket> decodeVersionNegotiation(
const ParsedLongHeaderInvariant& longHeaderInvariant,
folly::io::Cursor& cursor) {
Cursor& cursor) {
auto cursorLength = cursor.totalLength();
if (cursorLength < sizeof(QuicVersionType) ||
@ -1277,7 +1272,7 @@ ParsedLongHeaderInvariant::ParsedLongHeaderInvariant(
invariantLength(length) {}
folly::Expected<ParsedLongHeaderInvariant, TransportErrorCode>
parseLongHeaderInvariant(uint8_t initialByte, folly::io::Cursor& cursor) {
parseLongHeaderInvariant(uint8_t initialByte, Cursor& cursor) {
size_t initialLength = cursor.totalLength();
if (!cursor.canAdvance(sizeof(QuicVersionType))) {
VLOG(5) << "Not enough input bytes to read Version or connection-id";
@ -1355,7 +1350,7 @@ std::pair<PacketNum, size_t> parsePacketNumber(
folly::Expected<ParsedLongHeaderResult, TransportErrorCode> parseLongHeader(
uint8_t initialByte,
folly::io::Cursor& cursor) {
Cursor& cursor) {
if (getHeaderForm(initialByte) != HeaderForm::Long) {
VLOG(5) << "Bad header form bit";
return folly::makeUnexpected(TransportErrorCode::FRAME_ENCODING_ERROR);
@ -1393,7 +1388,7 @@ folly::Expected<ParsedLongHeaderResult, TransportErrorCode> parseLongHeader(
folly::Expected<ParsedLongHeader, TransportErrorCode> parseLongHeaderVariants(
LongHeader::Types type,
ParsedLongHeaderInvariant parsedLongHeaderInvariant,
folly::io::Cursor& cursor,
Cursor& cursor,
QuicNodeType nodeType) {
if (type == LongHeader::Types::Retry) {
// The integrity tag is kRetryIntegrityTagLen bytes in length, and the
@ -1472,7 +1467,7 @@ folly::Expected<ParsedLongHeader, TransportErrorCode> parseLongHeaderVariants(
folly::Expected<ShortHeaderInvariant, TransportErrorCode>
parseShortHeaderInvariants(
uint8_t initialByte,
folly::io::Cursor& cursor,
Cursor& cursor,
size_t dstConnIdSize) {
if (getHeaderForm(initialByte) != HeaderForm::Short) {
VLOG(5) << "Bad header form bit";
@ -1492,10 +1487,8 @@ parseShortHeaderInvariants(
return ShortHeaderInvariant(std::move(connId));
}
folly::Expected<ShortHeader, TransportErrorCode> parseShortHeader(
uint8_t initialByte,
folly::io::Cursor& cursor,
size_t dstConnIdSize) {
folly::Expected<ShortHeader, TransportErrorCode>
parseShortHeader(uint8_t initialByte, Cursor& cursor, size_t dstConnIdSize) {
if (getHeaderForm(initialByte) != HeaderForm::Short) {
VLOG(5) << "Bad header form bit";
return folly::makeUnexpected(TransportErrorCode::FRAME_ENCODING_ERROR);

View File

@ -60,7 +60,7 @@ struct ParsedLongHeaderInvariant {
*/
Optional<VersionNegotiationPacket> decodeVersionNegotiation(
const ParsedLongHeaderInvariant& longHeaderInvariant,
folly::io::Cursor& cursor);
Cursor& cursor);
/**
* Decodes a single regular QUIC packet from the cursor.
@ -87,89 +87,89 @@ Optional<VersionNegotiationPacket> decodeVersionNegotiation(
* when decoding fails.
*/
[[nodiscard]] folly::Expected<PaddingFrame, QuicError> decodePaddingFrame(
folly::io::Cursor& cursor);
Cursor& cursor);
[[nodiscard]] folly::Expected<RstStreamFrame, QuicError> decodeRstStreamFrame(
folly::io::Cursor& cursor,
Cursor& cursor,
bool reliable);
[[nodiscard]] folly::Expected<ConnectionCloseFrame, QuicError>
decodeConnectionCloseFrame(folly::io::Cursor& cursor);
decodeConnectionCloseFrame(Cursor& cursor);
[[nodiscard]] folly::Expected<ConnectionCloseFrame, QuicError>
decodeApplicationClose(folly::io::Cursor& cursor);
decodeApplicationClose(Cursor& cursor);
[[nodiscard]] folly::Expected<MaxDataFrame, QuicError> decodeMaxDataFrame(
folly::io::Cursor& cursor);
Cursor& cursor);
[[nodiscard]] folly::Expected<MaxStreamDataFrame, QuicError>
decodeMaxStreamDataFrame(folly::io::Cursor& cursor);
decodeMaxStreamDataFrame(Cursor& cursor);
[[nodiscard]] folly::Expected<MaxStreamsFrame, QuicError>
decodeBiDiMaxStreamsFrame(folly::io::Cursor& cursor);
decodeBiDiMaxStreamsFrame(Cursor& cursor);
[[nodiscard]] folly::Expected<MaxStreamsFrame, QuicError>
decodeUniMaxStreamsFrame(folly::io::Cursor& cursor);
decodeUniMaxStreamsFrame(Cursor& cursor);
[[nodiscard]] folly::Expected<PingFrame, QuicError> decodePingFrame(
folly::io::Cursor& cursor);
Cursor& cursor);
[[nodiscard]] folly::Expected<QuicFrame, QuicError> decodeKnobFrame(
folly::io::Cursor& cursor);
Cursor& cursor);
[[nodiscard]] folly::Expected<QuicSimpleFrame, QuicError>
decodeAckFrequencyFrame(folly::io::Cursor& cursor);
decodeAckFrequencyFrame(Cursor& cursor);
[[nodiscard]] folly::Expected<ImmediateAckFrame, QuicError>
decodeImmediateAckFrame(folly::io::Cursor& cursor);
decodeImmediateAckFrame(Cursor& cursor);
[[nodiscard]] folly::Expected<DataBlockedFrame, QuicError>
decodeDataBlockedFrame(folly::io::Cursor& cursor);
decodeDataBlockedFrame(Cursor& cursor);
[[nodiscard]] folly::Expected<StreamDataBlockedFrame, QuicError>
decodeStreamDataBlockedFrame(folly::io::Cursor& cursor);
decodeStreamDataBlockedFrame(Cursor& cursor);
[[nodiscard]] folly::Expected<StreamsBlockedFrame, QuicError>
decodeBiDiStreamsBlockedFrame(folly::io::Cursor& cursor);
decodeBiDiStreamsBlockedFrame(Cursor& cursor);
[[nodiscard]] folly::Expected<StreamsBlockedFrame, QuicError>
decodeUniStreamsBlockedFrame(folly::io::Cursor& cursor);
decodeUniStreamsBlockedFrame(Cursor& cursor);
[[nodiscard]] folly::Expected<NewConnectionIdFrame, QuicError>
decodeNewConnectionIdFrame(folly::io::Cursor& cursor);
decodeNewConnectionIdFrame(Cursor& cursor);
[[nodiscard]] folly::Expected<RetireConnectionIdFrame, QuicError>
decodeRetireConnectionIdFrame(folly::io::Cursor& cursor);
decodeRetireConnectionIdFrame(Cursor& cursor);
[[nodiscard]] folly::Expected<StopSendingFrame, QuicError>
decodeStopSendingFrame(folly::io::Cursor& cursor);
decodeStopSendingFrame(Cursor& cursor);
[[nodiscard]] folly::Expected<PathChallengeFrame, QuicError>
decodePathChallengeFrame(folly::io::Cursor& cursor);
decodePathChallengeFrame(Cursor& cursor);
[[nodiscard]] folly::Expected<PathResponseFrame, QuicError>
decodePathResponseFrame(folly::io::Cursor& cursor);
decodePathResponseFrame(Cursor& cursor);
[[nodiscard]] folly::Expected<ReadAckFrame, QuicError> decodeAckFrame(
folly::io::Cursor& cursor,
Cursor& cursor,
const PacketHeader& header,
const CodecParameters& params,
FrameType frameType = FrameType::ACK);
[[nodiscard]] folly::Expected<ReadAckFrame, QuicError> decodeAckExtendedFrame(
folly::io::Cursor& cursor,
Cursor& cursor,
const PacketHeader& header,
const CodecParameters& params);
[[nodiscard]] folly::Expected<QuicFrame, QuicError>
decodeAckFrameWithReceivedTimestamps(
folly::io::Cursor& cursor,
Cursor& cursor,
const PacketHeader& header,
const CodecParameters& params,
FrameType frameType);
[[nodiscard]] folly::Expected<QuicFrame, QuicError> decodeAckFrameWithECN(
folly::io::Cursor& cursor,
Cursor& cursor,
const PacketHeader& header,
const CodecParameters& params);
@ -179,16 +179,16 @@ decodeAckFrameWithReceivedTimestamps(
bool isGroupFrame = false);
[[nodiscard]] folly::Expected<ReadCryptoFrame, QuicError> decodeCryptoFrame(
folly::io::Cursor& cursor);
Cursor& cursor);
[[nodiscard]] folly::Expected<ReadNewTokenFrame, QuicError> decodeNewTokenFrame(
folly::io::Cursor& cursor);
Cursor& cursor);
[[nodiscard]] folly::Expected<HandshakeDoneFrame, QuicError>
decodeHandshakeDoneFrame(folly::io::Cursor& cursor);
decodeHandshakeDoneFrame(Cursor& cursor);
[[nodiscard]] folly::Expected<uint64_t, TransportErrorCode>
parsePlaintextRetryOrNewToken(folly::io::Cursor& cursor);
parsePlaintextRetryOrNewToken(Cursor& cursor);
[[nodiscard]] folly::Expected<DatagramFrame, QuicError> decodeDatagramFrame(
BufQueue& queue,
@ -201,7 +201,7 @@ parsePlaintextRetryOrNewToken(folly::io::Cursor& cursor);
* will be moved to the byte right after Source Connection ID.
*/
[[nodiscard]] folly::Expected<ParsedLongHeaderInvariant, TransportErrorCode>
parseLongHeaderInvariant(uint8_t initalByte, folly::io::Cursor& cursor);
parseLongHeaderInvariant(uint8_t initalByte, Cursor& cursor);
struct PacketLength {
// The length of the packet payload (including packet number)
@ -247,25 +247,25 @@ std::pair<PacketNum, size_t> parsePacketNumber(
// cursor: has to be point to the byte just past initialByte
[[nodiscard]] folly::Expected<ParsedLongHeaderResult, TransportErrorCode>
parseLongHeader(uint8_t initialByte, folly::io::Cursor& cursor);
parseLongHeader(uint8_t initialByte, Cursor& cursor);
// nodeType: Determine if we allow 0-len dst connection ids.
[[nodiscard]] folly::Expected<ParsedLongHeader, TransportErrorCode>
parseLongHeaderVariants(
LongHeader::Types type,
ParsedLongHeaderInvariant longHeaderInvariant,
folly::io::Cursor& cursor,
Cursor& cursor,
QuicNodeType nodeType = QuicNodeType::Server);
[[nodiscard]] folly::Expected<ShortHeaderInvariant, TransportErrorCode>
parseShortHeaderInvariants(
uint8_t initialByte,
folly::io::Cursor& cursor,
Cursor& cursor,
size_t dstConnIdSize = kDefaultConnectionIdSize);
[[nodiscard]] folly::Expected<ShortHeader, TransportErrorCode> parseShortHeader(
uint8_t initialByte,
folly::io::Cursor& cursor,
Cursor& cursor,
size_t dstConnIdSize = kDefaultConnectionIdSize);
[[nodiscard]] folly::Expected<uint64_t, QuicError>

View File

@ -43,7 +43,7 @@ ConnectionId::ConnectionId(const std::vector<uint8_t>& connidIn) {
}
}
ConnectionId::ConnectionId(folly::io::Cursor& cursor, size_t len) {
ConnectionId::ConnectionId(Cursor& cursor, size_t len) {
// Zero is special case for connids.
if (len == 0) {
connidLen = 0;

View File

@ -43,7 +43,7 @@ struct ConnectionId {
explicit ConnectionId(const std::vector<uint8_t>& connidIn);
explicit ConnectionId(folly::io::Cursor& cursor, size_t len);
explicit ConnectionId(Cursor& cursor, size_t len);
bool operator==(const ConnectionId& other) const;
bool operator!=(const ConnectionId& other) const;

View File

@ -20,7 +20,7 @@ ParsedHeaderResult::ParsedHeaderResult(
folly::Expected<ParsedHeaderResult, TransportErrorCode> parseHeader(
const folly::IOBuf& data) {
folly::io::Cursor cursor(&data);
Cursor cursor(&data);
if (!cursor.canAdvance(sizeof(uint8_t))) {
return folly::makeUnexpected(TransportErrorCode::FRAME_ENCODING_ERROR);
}

View File

@ -30,7 +30,7 @@ uint8_t decodeQuicIntegerLength(uint8_t firstByte) {
}
Optional<std::pair<uint64_t, size_t>> decodeQuicInteger(
folly::io::Cursor& cursor,
Cursor& cursor,
uint64_t atMost) {
// checks
if (atMost == 0 || !cursor.canAdvance(1)) {

View File

@ -101,7 +101,7 @@ encodeQuicInteger(uint64_t value, BufOp bufop, int outputSize) {
* read the int. It only advances the cursor in case of success.
*/
Optional<std::pair<uint64_t, size_t>> decodeQuicInteger(
folly::io::Cursor& cursor,
Cursor& cursor,
uint64_t atMost = sizeof(uint64_t));
/**

View File

@ -198,7 +198,7 @@ void RegularQuicPacketBuilder::insert(BufPtr buf) {
void RegularQuicPacketBuilder::insert(BufPtr buf, size_t limit) {
BufPtr streamData;
folly::io::Cursor cursor(buf.get());
Cursor cursor(buf.get());
cursor.clone(streamData, limit);
// reminaingBytes_ update is taken care of inside this insert call:
insert(std::move(streamData));
@ -206,7 +206,7 @@ void RegularQuicPacketBuilder::insert(BufPtr buf, size_t limit) {
void RegularQuicPacketBuilder::insert(const BufQueue& buf, size_t limit) {
BufPtr streamData;
folly::io::Cursor cursor(buf.front());
Cursor cursor(buf.front());
cursor.clone(streamData, limit);
// reminaingBytes_ update is taken care of inside this insert call:
insert(std::move(streamData));

View File

@ -24,7 +24,7 @@ QuicReadCodec::QuicReadCodec(QuicNodeType nodeType) : nodeType_(nodeType) {}
Optional<VersionNegotiationPacket> QuicReadCodec::tryParsingVersionNegotiation(
BufQueue& queue) {
folly::io::Cursor cursor(queue.front());
Cursor cursor(queue.front());
if (!cursor.canAdvance(sizeof(uint8_t))) {
return none;
}
@ -47,7 +47,7 @@ Optional<VersionNegotiationPacket> QuicReadCodec::tryParsingVersionNegotiation(
}
folly::Expected<ParsedLongHeader, TransportErrorCode> tryParseLongHeader(
folly::io::Cursor& cursor,
Cursor& cursor,
QuicNodeType nodeType) {
if (cursor.isAtEnd() || !cursor.canAdvance(sizeof(uint8_t))) {
return folly::makeUnexpected(TransportErrorCode::PROTOCOL_VIOLATION);
@ -101,7 +101,7 @@ static PacketDropReason getDecryptErrorReason(ProtectionType protectionType) {
CodecResult QuicReadCodec::parseLongHeaderPacket(
BufQueue& queue,
const AckStates& ackStates) {
folly::io::Cursor cursor(queue.front());
Cursor cursor(queue.front());
const uint8_t initialByte = *cursor.peekBytes().data();
auto res = tryParseLongHeader(cursor, nodeType_);
@ -272,7 +272,7 @@ CodecResult QuicReadCodec::tryParseShortHeaderPacket(
BufPtr data,
const AckStates& ackStates,
size_t dstConnIdSize,
folly::io::Cursor& cursor) {
Cursor& cursor) {
// TODO: allow other connid lengths from the state.
size_t packetNumberOffset = 1 + dstConnIdSize;
PacketNum expectedNextPacketNum =
@ -412,7 +412,7 @@ CodecResult QuicReadCodec::parsePacket(
return CodecResult(Nothing());
}
DCHECK(!queue.front()->isChained());
folly::io::Cursor cursor(queue.front());
Cursor cursor(queue.front());
if (!cursor.canAdvance(sizeof(uint8_t))) {
return CodecResult(Nothing());
}

View File

@ -99,7 +99,7 @@ struct CodecResult {
* Returns an error if parsing is unsuccessful.
*/
folly::Expected<ParsedLongHeader, TransportErrorCode> tryParseLongHeader(
folly::io::Cursor& cursor,
Cursor& cursor,
QuicNodeType nodeType);
class QuicReadCodec {
@ -202,7 +202,7 @@ class QuicReadCodec {
BufPtr data,
const AckStates& ackStates,
size_t dstConnIdSize,
folly::io::Cursor& cursor);
Cursor& cursor);
CodecResult parseLongHeaderPacket(
BufQueue& queue,
const AckStates& ackStates);

View File

@ -1072,10 +1072,8 @@ struct ShortHeader {
private:
ShortHeader() = delete;
bool readInitialByte(uint8_t initalByte);
bool readConnectionId(folly::io::Cursor& cursor);
bool readPacketNum(
PacketNum largestReceivedUdpPacketNum,
folly::io::Cursor& cursor);
bool readConnectionId(Cursor& cursor);
bool readPacketNum(PacketNum largestReceivedUdpPacketNum, Cursor& cursor);
private:
PacketNum packetSequenceNum_{0};

View File

@ -294,7 +294,7 @@ TEST_F(DecodeTest, ValidAckFrame) {
numAdditionalBlocks,
firstAckBlockLength,
ackBlocks);
folly::io::Cursor cursor(result.get());
Cursor cursor(result.get());
auto res = decodeAckFrame(
cursor,
makeHeader(),
@ -325,7 +325,7 @@ TEST_F(DecodeTest, AckEcnFrame) {
false, // useRealValuesForLargestAcked
false, // useRealValuesForAckDelay
true); // addEcnCounts
folly::io::Cursor cursor(result.get());
Cursor cursor(result.get());
auto res = decodeAckFrameWithECN(
cursor,
makeHeader(),
@ -362,7 +362,7 @@ TEST_F(DecodeTest, AckExtendedFrameWithECN) {
false, // useRealValuesForAckDelay
true, // addEcnCounts
true); // useExtendedAck
folly::io::Cursor cursor(result.get());
Cursor cursor(result.get());
auto ackFrameRes = decodeAckExtendedFrame(
cursor,
makeHeader(),
@ -406,7 +406,7 @@ TEST_F(DecodeTest, AckExtendedFrameWithNoFeatures) {
false, // useRealValuesForAckDelay
false, // addEcnCounts
true); // useExtendedAck
folly::io::Cursor cursor(result.get());
Cursor cursor(result.get());
auto ackFrameRes = decodeAckExtendedFrame(
cursor,
makeHeader(),
@ -444,7 +444,7 @@ TEST_F(DecodeTest, AckExtendedFrameThrowsWithUnsupportedFeatures) {
false, // useRealValuesForAckDelay
true, // addEcnCounts
true); // useExtendedAck
folly::io::Cursor cursor(result.get());
Cursor cursor(result.get());
// Try to decode extended ack with ECN but we only support Timestamps
auto decodeResult = decodeAckExtendedFrame(
@ -474,7 +474,7 @@ TEST_F(DecodeTest, AckFrameLargestAckExceedsRange) {
firstAckBlockLength,
{},
true);
folly::io::Cursor cursor(result.get());
Cursor cursor(result.get());
auto res = decodeAckFrame(
cursor,
makeHeader(),
@ -498,7 +498,7 @@ TEST_F(DecodeTest, AckFrameLargestAckInvalid) {
firstAckBlockLength,
{},
true);
folly::io::Cursor cursor(result.get());
Cursor cursor(result.get());
auto res = decodeAckFrame(
cursor,
makeHeader(),
@ -521,7 +521,7 @@ TEST_F(DecodeTest, AckFrameDelayEncodingInvalid) {
{},
false,
true);
folly::io::Cursor cursor(result.get());
Cursor cursor(result.get());
auto res = decodeAckFrame(
cursor,
makeHeader(),
@ -538,7 +538,7 @@ TEST_F(DecodeTest, AckFrameDelayExceedsRange) {
QuicInteger firstAckBlockLength(10);
auto result = createAckFrame(
largestAcked, ackDelay, numAdditionalBlocks, firstAckBlockLength);
folly::io::Cursor cursor(result.get());
Cursor cursor(result.get());
auto res = decodeAckFrame(
cursor,
makeHeader(),
@ -562,7 +562,7 @@ TEST_F(DecodeTest, AckFrameAdditionalBlocksUnderflow) {
numAdditionalBlocks,
firstAckBlockLength,
ackBlocks);
folly::io::Cursor cursor(result.get());
Cursor cursor(result.get());
auto res = decodeAckFrame(
cursor,
makeHeader(),
@ -588,7 +588,7 @@ TEST_F(DecodeTest, AckFrameAdditionalBlocksOverflow) {
numAdditionalBlocks,
firstAckBlockLength,
ackBlocks);
folly::io::Cursor cursor(result.get());
Cursor cursor(result.get());
ASSERT_FALSE(
decodeAckFrame(
cursor,
@ -609,7 +609,7 @@ TEST_F(DecodeTest, AckFrameMissingFields) {
auto result1 = createAckFrame(
largestAcked, none, numAdditionalBlocks, firstAckBlockLength, ackBlocks);
folly::io::Cursor cursor1(result1.get());
Cursor cursor1(result1.get());
auto res = decodeAckFrame(
cursor1,
@ -620,7 +620,7 @@ TEST_F(DecodeTest, AckFrameMissingFields) {
auto result2 = createAckFrame(
largestAcked, ackDelay, none, firstAckBlockLength, ackBlocks);
folly::io::Cursor cursor2(result2.get());
Cursor cursor2(result2.get());
res = decodeAckFrame(
cursor2,
makeHeader(),
@ -630,7 +630,7 @@ TEST_F(DecodeTest, AckFrameMissingFields) {
auto result3 = createAckFrame(
largestAcked, ackDelay, none, firstAckBlockLength, ackBlocks);
folly::io::Cursor cursor3(result3.get());
Cursor cursor3(result3.get());
res = decodeAckFrame(
cursor3,
makeHeader(),
@ -640,7 +640,7 @@ TEST_F(DecodeTest, AckFrameMissingFields) {
auto result4 = createAckFrame(
largestAcked, ackDelay, numAdditionalBlocks, none, ackBlocks);
folly::io::Cursor cursor4(result4.get());
Cursor cursor4(result4.get());
res = decodeAckFrame(
cursor4,
makeHeader(),
@ -650,7 +650,7 @@ TEST_F(DecodeTest, AckFrameMissingFields) {
auto result5 = createAckFrame(
largestAcked, ackDelay, numAdditionalBlocks, firstAckBlockLength, {});
folly::io::Cursor cursor5(result5.get());
Cursor cursor5(result5.get());
res = decodeAckFrame(
cursor5,
makeHeader(),
@ -667,7 +667,7 @@ TEST_F(DecodeTest, AckFrameFirstBlockLengthInvalid) {
auto result = createAckFrame(
largestAcked, ackDelay, numAdditionalBlocks, firstAckBlockLength);
folly::io::Cursor cursor(result.get());
Cursor cursor(result.get());
auto res = decodeAckFrame(
cursor,
makeHeader(),
@ -692,7 +692,7 @@ TEST_F(DecodeTest, AckFrameBlockLengthInvalid) {
numAdditionalBlocks,
firstAckBlockLength,
ackBlocks);
folly::io::Cursor cursor(result.get());
Cursor cursor(result.get());
auto res = decodeAckFrame(
cursor,
makeHeader(),
@ -717,7 +717,7 @@ TEST_F(DecodeTest, AckFrameBlockGapInvalid) {
numAdditionalBlocks,
firstAckBlockLength,
ackBlocks);
folly::io::Cursor cursor(result.get());
Cursor cursor(result.get());
auto res = decodeAckFrame(
cursor,
makeHeader(),
@ -743,7 +743,7 @@ TEST_F(DecodeTest, AckFrameBlockLengthZero) {
numAdditionalBlocks,
firstAckBlockLength,
ackBlocks);
folly::io::Cursor cursor(result.get());
Cursor cursor(result.get());
auto res = decodeAckFrame(
cursor,
@ -863,12 +863,12 @@ std::unique_ptr<folly::IOBuf> CreateMaxStreamsIdFrame(
void MaxStreamsIdCheckSuccess(StreamId maxStreamsId) {
std::unique_ptr<folly::IOBuf> buf = CreateMaxStreamsIdFrame(maxStreamsId);
folly::io::Cursor cursorBiDi(buf.get());
Cursor cursorBiDi(buf.get());
auto maxStreamsBiDiFrameRes = decodeBiDiMaxStreamsFrame(cursorBiDi);
ASSERT_TRUE(maxStreamsBiDiFrameRes.hasValue());
EXPECT_EQ(maxStreamsBiDiFrameRes->maxStreams, maxStreamsId);
folly::io::Cursor cursorUni(buf.get());
Cursor cursorUni(buf.get());
auto maxStreamsUniFrameRes = decodeUniMaxStreamsFrame(cursorUni);
ASSERT_TRUE(maxStreamsUniFrameRes.hasValue());
EXPECT_EQ(maxStreamsUniFrameRes->maxStreams, maxStreamsId);
@ -878,12 +878,12 @@ void MaxStreamsIdCheckSuccess(StreamId maxStreamsId) {
void MaxStreamsIdCheckInvalid(StreamId maxStreamsId) {
std::unique_ptr<folly::IOBuf> buf = CreateMaxStreamsIdFrame(maxStreamsId);
folly::io::Cursor cursorBiDi(buf.get());
Cursor cursorBiDi(buf.get());
auto bidiResult = decodeBiDiMaxStreamsFrame(cursorBiDi);
EXPECT_TRUE(bidiResult.hasError());
EXPECT_EQ(bidiResult.error().code, TransportErrorCode::FRAME_ENCODING_ERROR);
folly::io::Cursor cursorUni(buf.get());
Cursor cursorUni(buf.get());
auto uniResult = decodeUniMaxStreamsFrame(cursorUni);
EXPECT_TRUE(uniResult.hasError());
EXPECT_EQ(uniResult.error().code, TransportErrorCode::FRAME_ENCODING_ERROR);
@ -904,7 +904,7 @@ TEST_F(DecodeTest, CryptoDecodeSuccess) {
QuicInteger length(1);
auto cryptoFrame =
createCryptoFrame(offset, length, folly::IOBuf::copyBuffer("a"));
folly::io::Cursor cursor(cryptoFrame.get());
Cursor cursor(cryptoFrame.get());
auto decodedFrame = decodeCryptoFrame(cursor);
EXPECT_EQ(decodedFrame->offset, 10);
EXPECT_EQ(decodedFrame->data->computeChainDataLength(), 1);
@ -914,7 +914,7 @@ TEST_F(DecodeTest, CryptoOffsetNotPresent) {
QuicInteger length(1);
auto cryptoFrame =
createCryptoFrame(none, length, folly::IOBuf::copyBuffer("a"));
folly::io::Cursor cursor(cryptoFrame.get());
Cursor cursor(cryptoFrame.get());
auto result = decodeCryptoFrame(cursor);
EXPECT_TRUE(result.hasError());
EXPECT_EQ(result.error().code, TransportErrorCode::FRAME_ENCODING_ERROR);
@ -923,7 +923,7 @@ TEST_F(DecodeTest, CryptoOffsetNotPresent) {
TEST_F(DecodeTest, CryptoLengthNotPresent) {
QuicInteger offset(0);
auto cryptoFrame = createCryptoFrame(offset, none, nullptr);
folly::io::Cursor cursor(cryptoFrame.get());
Cursor cursor(cryptoFrame.get());
auto result = decodeCryptoFrame(cursor);
EXPECT_TRUE(result.hasError());
EXPECT_EQ(result.error().code, TransportErrorCode::FRAME_ENCODING_ERROR);
@ -934,7 +934,7 @@ TEST_F(DecodeTest, CryptoIncorrectDataLength) {
QuicInteger length(10);
auto cryptoFrame =
createCryptoFrame(offset, length, folly::IOBuf::copyBuffer("a"));
folly::io::Cursor cursor(cryptoFrame.get());
Cursor cursor(cryptoFrame.get());
auto result = decodeCryptoFrame(cursor);
EXPECT_TRUE(result.hasError());
EXPECT_EQ(result.error().code, TransportErrorCode::FRAME_ENCODING_ERROR);
@ -945,14 +945,14 @@ TEST_F(DecodeTest, PaddingFrameTest) {
buf->append(1);
memset(buf->writableData(), 0, 1);
folly::io::Cursor cursor(buf.get());
Cursor cursor(buf.get());
ASSERT_FALSE(decodePaddingFrame(cursor).hasError());
}
TEST_F(DecodeTest, PaddingFrameNoBytesTest) {
auto buf = folly::IOBuf::create(sizeof(UnderlyingFrameType));
folly::io::Cursor cursor(buf.get());
Cursor cursor(buf.get());
ASSERT_FALSE(decodePaddingFrame(cursor).hasError());
}
@ -964,7 +964,7 @@ TEST_F(DecodeTest, DecodeMultiplePaddingInterleavedTest) {
// something which is not padding
memset(buf->writableData() + 10, 5, 1);
folly::io::Cursor cursor(buf.get());
Cursor cursor(buf.get());
ASSERT_FALSE(decodePaddingFrame(cursor).hasError());
// If we encountered an interleaved frame, leave the whole thing
// as is
@ -976,7 +976,7 @@ TEST_F(DecodeTest, DecodeMultiplePaddingTest) {
buf->append(10);
memset(buf->writableData(), 0, 10);
folly::io::Cursor cursor(buf.get());
Cursor cursor(buf.get());
ASSERT_FALSE(decodePaddingFrame(cursor).hasError());
EXPECT_EQ(cursor.totalLength(), 0);
}
@ -1000,14 +1000,14 @@ TEST_F(DecodeTest, NewTokenDecodeSuccess) {
QuicInteger length(1);
auto newTokenFrame =
createNewTokenFrame(length, folly::IOBuf::copyBuffer("a"));
folly::io::Cursor cursor(newTokenFrame.get());
Cursor cursor(newTokenFrame.get());
auto decodedFrame = decodeNewTokenFrame(cursor);
EXPECT_EQ(decodedFrame->token->computeChainDataLength(), 1);
}
TEST_F(DecodeTest, NewTokenLengthNotPresent) {
auto newTokenFrame = createNewTokenFrame(none, folly::IOBuf::copyBuffer("a"));
folly::io::Cursor cursor(newTokenFrame.get());
Cursor cursor(newTokenFrame.get());
auto result = decodeNewTokenFrame(cursor);
EXPECT_TRUE(result.hasError());
EXPECT_EQ(result.error().code, TransportErrorCode::FRAME_ENCODING_ERROR);
@ -1017,7 +1017,7 @@ TEST_F(DecodeTest, NewTokenIncorrectDataLength) {
QuicInteger length(10);
auto newTokenFrame =
createNewTokenFrame(length, folly::IOBuf::copyBuffer("a"));
folly::io::Cursor cursor(newTokenFrame.get());
Cursor cursor(newTokenFrame.get());
auto result = decodeNewTokenFrame(cursor);
EXPECT_TRUE(result.hasError());
EXPECT_EQ(result.error().code, TransportErrorCode::FRAME_ENCODING_ERROR);
@ -1033,7 +1033,7 @@ TEST_F(DecodeTest, ParsePlaintextNewToken) {
NewToken newToken(clientIp, timestampInMs);
BufPtr plaintextNewToken = newToken.getPlaintextToken();
folly::io::Cursor cursor(plaintextNewToken.get());
Cursor cursor(plaintextNewToken.get());
auto parseResult = parsePlaintextRetryOrNewToken(cursor);
@ -1054,7 +1054,7 @@ TEST_F(DecodeTest, ParsePlaintextRetryToken) {
RetryToken retryToken(odcid, clientIp, clientPort, timestampInMs);
BufPtr plaintextRetryToken = retryToken.getPlaintextToken();
folly::io::Cursor cursor(plaintextRetryToken.get());
Cursor cursor(plaintextRetryToken.get());
/**
* Now we continue with the parsing logic here.
@ -1107,7 +1107,7 @@ TEST_F(DecodeTest, AckFrequencyFrameDecodeValid) {
sequenceNumber, packetTolerance, maxAckDelay, reorderThreshold);
ASSERT_NE(ackFrequencyFrame, nullptr);
folly::io::Cursor cursor(ackFrequencyFrame.get());
Cursor cursor(ackFrequencyFrame.get());
auto res = decodeAckFrequencyFrame(cursor);
EXPECT_TRUE(res.hasValue());
auto decodedFrame = *res->asAckFrequencyFrame();
@ -1125,7 +1125,7 @@ TEST_F(DecodeTest, AckFrequencyFrameDecodeInvalidReserved) {
sequenceNumber, packetTolerance, maxAckDelay, none);
ASSERT_NE(ackFrequencyFrame, nullptr);
folly::io::Cursor cursor(ackFrequencyFrame.get());
Cursor cursor(ackFrequencyFrame.get());
auto res = decodeAckFrequencyFrame(cursor);
EXPECT_TRUE(res.hasError());
EXPECT_EQ(res.error().code, TransportErrorCode::FRAME_ENCODING_ERROR);

View File

@ -16,7 +16,7 @@ namespace quic::test {
TEST(ConnectionIdTest, TestConnidLen) {
std::string out = folly::unhexlify("ffaabbee00");
folly::IOBuf buf = folly::IOBuf::wrapBufferAsValue(out.data(), out.size());
folly::io::Cursor cursor(&buf);
Cursor cursor(&buf);
ConnectionId connid(cursor, out.size());
EXPECT_EQ(static_cast<size_t>(connid.size()), out.size());
for (size_t i = 0; i < connid.size(); ++i) {
@ -29,7 +29,7 @@ TEST(ConnectionIdTest, TestConnidLen) {
TEST(ConnectionIdTest, TestZeroLenConnid) {
std::string out;
folly::IOBuf buf = folly::IOBuf::wrapBufferAsValue(out.data(), out.size());
folly::io::Cursor cursor(&buf);
Cursor cursor(&buf);
ConnectionId connid(cursor, out.size());
EXPECT_EQ(static_cast<size_t>(connid.size()), out.size());
}

View File

@ -38,7 +38,7 @@ TEST_P(QuicIntegerDecodeTest, DecodeTrim) {
wrappedEncoded->trimEnd(std::min(
(unsigned long)(wrappedEncoded->computeChainDataLength()),
(unsigned long)(GetParam().encodedLength - atMost)));
folly::io::Cursor cursor(wrappedEncoded.get());
Cursor cursor(wrappedEncoded.get());
auto originalLength = cursor.length();
auto decodedValue = decodeQuicInteger(cursor);
if (GetParam().error || atMost != GetParam().encodedLength) {
@ -57,7 +57,7 @@ TEST_P(QuicIntegerDecodeTest, DecodeAtMost) {
auto wrappedEncoded = IOBuf::copyBuffer(encodedBytes);
for (int atMost = 0; atMost <= GetParam().encodedLength; atMost++) {
folly::io::Cursor cursor(wrappedEncoded.get());
Cursor cursor(wrappedEncoded.get());
auto originalLength = cursor.length();
auto decodedValue = decodeQuicInteger(cursor, atMost);
if (GetParam().error || atMost != GetParam().encodedLength) {

View File

@ -622,8 +622,8 @@ TEST_F(QuicPacketBuilderTest, PseudoRetryPacket) {
BufPtr expectedIntegrityTag = folly::IOBuf::copyBuffer(
"\xd1\x69\x26\xd8\x1f\x6f\x9c\xa2\x95\x3a\x8a\xa4\x57\x5e\x1e\x49");
folly::io::Cursor cursorActual(integrityTag.get());
folly::io::Cursor cursorExpected(expectedIntegrityTag.get());
Cursor cursorActual(integrityTag.get());
Cursor cursorExpected(expectedIntegrityTag.get());
EXPECT_TRUE(folly::IOBufEqualTo()(*expectedIntegrityTag, *integrityTag));
}
@ -685,7 +685,7 @@ TEST_F(QuicPacketBuilderTest, RetryPacketValid) {
EXPECT_EQ(retryPacket->computeChainDataLength(), expectedPacketLen);
// initial byte
folly::io::Cursor cursor(retryPacket.get());
Cursor cursor(retryPacket.get());
auto initialByte = cursor.readBE<uint8_t>();
EXPECT_EQ(initialByte & 0xf0, 0xf0);

View File

@ -723,7 +723,7 @@ TEST_F(QuicReadCodecTest, TestInitialPacketExtractToken) {
auto packetQueue =
bufToQueue(packetToBufCleartext(packet, *aead, *headerCipher, packetNum));
folly::io::Cursor cursor(packetQueue.front());
Cursor cursor(packetQueue.front());
auto res = tryParseLongHeader(cursor, QuicNodeType::Client);
EXPECT_FALSE(res.hasError());
auto parsedLongHeader = std::move(res.value());

View File

@ -124,7 +124,7 @@ void setupCommonExpects(MockQuicPacketBuilder& pktBuilder) {
.WillRepeatedly(WithArgs<0, 1>(Invoke([&](BufPtr& buf, size_t limit) {
pktBuilder.remaining_ -= limit;
std::unique_ptr<folly::IOBuf> cloneBuf;
folly::io::Cursor cursor(buf.get());
Cursor cursor(buf.get());
cursor.clone(cloneBuf, limit);
pktBuilder.appender_.insert(std::move(cloneBuf));
})));
@ -147,7 +147,7 @@ void setupCommonExpects(MockQuicPacketBuilder& pktBuilder) {
WithArgs<0, 1>(Invoke([&](const BufQueue& buf, size_t limit) {
pktBuilder.remaining_ -= limit;
std::unique_ptr<folly::IOBuf> cloneBuf;
folly::io::Cursor cursor(buf.front());
Cursor cursor(buf.front());
cursor.clone(cloneBuf, limit);
pktBuilder.appender_.insert(std::move(cloneBuf));
})));
@ -883,7 +883,7 @@ TEST_F(QuicWriteCodecTest, WriteFinToEmptyPacket) {
EXPECT_TRUE(folly::IOBufEqualTo()(inputBuf, outputBuf));
auto wireBuf = std::move(builtOut.second);
folly::io::Cursor cursor(wireBuf.get());
Cursor cursor(wireBuf.get());
BufQueue queue;
queue.append(wireBuf->clone());
auto decodedFrame = quic::parseFrame(
@ -1582,7 +1582,7 @@ TEST_P(QuicWriteCodecTest, WriteExponentInLongHeaderPacket) {
EXPECT_TRUE(ackFrameWriteResult.hasValue());
auto builtOut = std::move(pktBuilder).buildLongHeaderPacket();
auto wireBuf = std::move(builtOut.second);
folly::io::Cursor cursor(wireBuf.get());
Cursor cursor(wireBuf.get());
BufQueue queue;
queue.append(wireBuf->clone());
auto decodedFrameResult = quic::parseFrame(
@ -2182,7 +2182,7 @@ TEST_F(QuicWriteCodecTest, WriteMaxStreamId) {
EXPECT_EQ(i, resultMaxStreamIdFrame.maxStreams);
auto wireBuf = std::move(builtOut.second);
folly::io::Cursor cursor(wireBuf.get());
Cursor cursor(wireBuf.get());
BufQueue queue;
queue.append(wireBuf->clone());
QuicFrame decodedFrame = parseQuicFrame(queue);

View File

@ -24,7 +24,7 @@ std::pair<uint8_t, BufPtr> encodeShortHeader(const ShortHeader& header) {
CHECK(!builder.encodePacketHeader().hasError());
auto packet = std::move(builder).buildPacket();
BufPtr out;
folly::io::Cursor cursor(&packet.header);
Cursor cursor(&packet.header);
auto initialByte = cursor.readBE<uint8_t>();
cursor.clone(out, cursor.totalLength());
return std::make_pair(initialByte, std::move(out));
@ -63,7 +63,7 @@ folly::Expected<ParsedLongHeaderResult, TransportErrorCode> makeLongHeader(
0 /* largestAcked */);
CHECK(!builder.encodePacketHeader().hasError());
auto packet = packetToBuf(std::move(builder).buildPacket());
folly::io::Cursor cursor(packet.get());
Cursor cursor(packet.get());
uint8_t initialByte = cursor.readBE<uint8_t>();
return parseLongHeader(initialByte, cursor);
}
@ -95,7 +95,7 @@ TEST_F(TypesTest, LongHeaderEmptyInput) {
uint8_t versionNegotiation = LongHeader::kPacketTypeMask;
auto buf = folly::IOBuf::create(0);
buf->append(0);
folly::io::Cursor cursor(buf.get());
Cursor cursor(buf.get());
EXPECT_FALSE(parseLongHeader(versionNegotiation, cursor).hasValue());
}
@ -114,7 +114,7 @@ TEST_F(TypesTest, LongHeaderSmallInput) {
wcursor.writeBE<uint8_t>(2);
wcursor.writeBE<uint8_t>(3);
folly::io::Cursor cursor(buf.get());
Cursor cursor(buf.get());
EXPECT_FALSE(parseLongHeader(clientCleartext, cursor).hasValue());
}
@ -131,7 +131,7 @@ TEST_F(TypesTest, LongHeaderInvalid) {
wcursor.writeBE<uint32_t>(1234);
wcursor.writeBE<QuicVersionType>(static_cast<QuicVersionType>(version));
folly::io::Cursor cursor(buf.get());
Cursor cursor(buf.get());
EXPECT_FALSE(parseLongHeader(badInitialValue, cursor).hasValue());
}
@ -140,7 +140,7 @@ TEST_F(TypesTest, ShortHeader) {
auto connId = getTestConnectionId();
ShortHeader testHeader1(ProtectionType::KeyPhaseZero, connId, packetNum);
auto result1 = encodeShortHeader(testHeader1);
folly::io::Cursor cursor1(result1.second.get());
Cursor cursor1(result1.second.get());
auto shortHeader1 = *parseShortHeader(result1.first, cursor1);
EXPECT_EQ(ProtectionType::KeyPhaseZero, shortHeader1.getProtectionType());
EXPECT_EQ(connId, shortHeader1.getConnectionId());
@ -148,7 +148,7 @@ TEST_F(TypesTest, ShortHeader) {
// Empty buffer
auto buf4 = folly::IOBuf::create(0);
buf4->append(0);
folly::io::Cursor cursor4(buf4.get());
Cursor cursor4(buf4.get());
EXPECT_FALSE(parseShortHeader(0x01, cursor4).hasValue());
}
@ -165,7 +165,7 @@ TEST_F(TypesTest, ShortHeaderGetConnectionIdTest) {
ShortHeader testHeader(ProtectionType::KeyPhaseZero, connId, packetNum);
auto result = encodeShortHeader(testHeader);
folly::io::Cursor cursor(result.second.get());
Cursor cursor(result.second.get());
auto shortHeader = *parseShortHeader(result.first, cursor);
EXPECT_EQ(connId, shortHeader.getConnectionId());
}

View File

@ -374,7 +374,7 @@ TEST(BufWriterTest, BasicWrite) {
writer.writeBE(sixtyfour);
testBuffer->append(writer.getBytesWritten());
folly::io::Cursor reader(testBuffer.get());
Cursor reader(testBuffer.get());
EXPECT_EQ(8, reader.template readBE<uint8_t>());
EXPECT_EQ(16, reader.template readBE<uint16_t>());
EXPECT_EQ(32, reader.template readBE<uint32_t>());
@ -404,7 +404,7 @@ TEST(BufWriterTest, Push) {
folly::IOBuf::copyBuffer("All you're gonna see it someday");
writer.push(inputBuffer->data(), inputBuffer->computeChainDataLength());
testBuffer->append(writer.getBytesWritten());
folly::io::Cursor reader(testBuffer.get());
Cursor reader(testBuffer.get());
EXPECT_EQ(
"All you're gonna see it someday",
reader.readFixedString(inputBuffer->computeChainDataLength()));
@ -418,7 +418,7 @@ TEST(BufWriterTest, InsertSingle) {
auto len = inputBuffer->computeChainDataLength();
writer.insert(inputBuffer.get());
testBuffer->append(writer.getBytesWritten());
folly::io::Cursor reader(testBuffer.get());
Cursor reader(testBuffer.get());
EXPECT_EQ(inputBuffer->to<string>(), reader.readFixedString(len));
}
@ -434,7 +434,7 @@ TEST(BufWriterTest, InsertChain) {
auto len = inputBuffer->computeChainDataLength();
writer.insert(inputBuffer.get());
testBuffer->append(writer.getBytesWritten());
folly::io::Cursor reader(testBuffer.get());
Cursor reader(testBuffer.get());
EXPECT_EQ(
"Cause I lost you and now what am i to do?"
" Can't believe that we are through."
@ -454,7 +454,7 @@ TEST(BufWriterTest, BackFill) {
bufWriter.backFill(
(uint8_t*)testInput3.data(), testInput3.size(), testInput1.size());
testBuffer->append(bufWriter.getBytesWritten());
folly::io::Cursor reader(testBuffer.get());
Cursor reader(testBuffer.get());
EXPECT_EQ(
"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15",
reader.readFixedString(
@ -468,7 +468,7 @@ TEST(BufWriterTest, BufQueueCopy) {
BufWriter bufWriter(outputBuffer->writableTail(), 200);
bufWriter.insert(queue.front(), queue.chainLength());
outputBuffer->append(bufWriter.getBytesWritten());
folly::io::Cursor reader(outputBuffer.get());
Cursor reader(outputBuffer.get());
EXPECT_EQ(
"I feel like I'm drowning", reader.readFixedString(queue.chainLength()));
}
@ -480,7 +480,7 @@ TEST(BufWriterTest, BufQueueCopyPartial) {
BufWriter bufWriter(outputBuffer->writableTail(), 200);
bufWriter.insert(queue.front(), 6);
outputBuffer->append(bufWriter.getBytesWritten());
folly::io::Cursor reader(outputBuffer.get());
Cursor reader(outputBuffer.get());
EXPECT_EQ(
"I feel", reader.readFixedString(outputBuffer->computeChainDataLength()));
}
@ -493,7 +493,7 @@ TEST(BufWriterTest, BufQueueChainCopy) {
BufWriter bufWriter(outputBuffer->writableTail(), 1000);
bufWriter.insert(queue.front(), queue.chainLength());
outputBuffer->append(bufWriter.getBytesWritten());
folly::io::Cursor reader(outputBuffer.get());
Cursor reader(outputBuffer.get());
EXPECT_EQ(
"I'm a hotpot. You mere are hotpot soup base.",
reader.readFixedString(queue.chainLength()));
@ -509,7 +509,7 @@ TEST(BufWriterTest, BufQueueChainCopyPartial) {
BufWriter bufWriter(outputBuffer->writableTail(), 1000);
bufWriter.insert(queue.front(), testStr1.size() + 10);
outputBuffer->append(bufWriter.getBytesWritten());
folly::io::Cursor reader(outputBuffer.get());
Cursor reader(outputBuffer.get());
EXPECT_EQ(
folly::to<std::string>(testStr1, "That you l"),
reader.readFixedString(testStr1.size() + 10));
@ -528,7 +528,7 @@ TEST(BufWriterTest, BufQueueChainCopyTooLargeLimit) {
bufWriter.insert(
queue.front(), (testStr1.size() + testStr2.size() + testStr3.size()) * 5);
outputBuffer->append(bufWriter.getBytesWritten());
folly::io::Cursor reader(outputBuffer.get());
Cursor reader(outputBuffer.get());
EXPECT_EQ(
"I see trees of green. "
"Red rose too. "
@ -549,7 +549,7 @@ TEST(BufWriterTest, TwoWriters) {
auto inputBuffer2 = folly::IOBuf::copyBuffer(" Saint");
bufWriter2.insert(inputBuffer2.get());
outputBuffer->append(bufWriter2.getBytesWritten());
folly::io::Cursor reader(outputBuffer.get());
Cursor reader(outputBuffer.get());
EXPECT_EQ(15, outputBuffer->length());
EXPECT_EQ("Destroyer Saint", reader.readFixedString(outputBuffer->length()));
}
@ -563,7 +563,7 @@ TEST(BufWriterTest, InsertSingleByteChainedRange) {
ChainedByteRangeHead cbrh(inputBuffer);
writer.insert(&cbrh);
testBuffer->append(writer.getBytesWritten());
folly::io::Cursor reader(testBuffer.get());
Cursor reader(testBuffer.get());
EXPECT_EQ(
inputBuffer->computeChainDataLength(),
testBuffer->computeChainDataLength());
@ -576,7 +576,7 @@ TEST(BufWriterTest, InsertZeroLen) {
auto inputBuffer = folly::IOBuf::copyBuffer("");
ChainedByteRangeHead cbrh(inputBuffer);
writer.insert(&cbrh);
folly::io::Cursor reader(testBuffer.get());
Cursor reader(testBuffer.get());
EXPECT_EQ(testBuffer->computeChainDataLength(), 0);
}
@ -588,7 +588,7 @@ TEST(BufWriterTest, InsertSingleByteChainedRangeWithLimit) {
ChainedByteRangeHead cbrh(inputBuffer);
writer.insert(&cbrh, 10);
testBuffer->append(writer.getBytesWritten());
folly::io::Cursor reader(testBuffer.get());
Cursor reader(testBuffer.get());
EXPECT_EQ(testBuffer->computeChainDataLength(), 10);
EXPECT_EQ("Steady on ", reader.readFixedString(10));
}
@ -606,7 +606,7 @@ TEST(BufWriterTest, InsertChainByteChainedRange) {
ChainedByteRangeHead cbrh(inputBuffer);
writer.insert(&cbrh);
testBuffer->append(writer.getBytesWritten());
folly::io::Cursor reader(testBuffer.get());
Cursor reader(testBuffer.get());
EXPECT_EQ(testBuffer->computeChainDataLength(), len);
EXPECT_EQ(
"Cause I lost you and now what am i to do?"

View File

@ -66,7 +66,7 @@ inline void removeDuplicateParams(std::vector<TransportParameter>& params) {
inline void decodeVarintParams(
std::vector<TransportParameter>& parameters,
folly::io::Cursor& cursor) {
Cursor& cursor) {
while (!cursor.isAtEnd()) {
auto id = decodeQuicInteger(cursor);
if (!id) {
@ -126,7 +126,7 @@ inline quic::Optional<quic::ClientTransportParameters> getClientExtension(
return quic::none;
}
quic::ClientTransportParameters parameters;
folly::io::Cursor cursor(it->extension_data.get());
quic::Cursor cursor(it->extension_data.get());
decodeVarintParams(parameters.parameters, cursor);
return parameters;
}
@ -140,7 +140,7 @@ inline quic::Optional<quic::ServerTransportParameters> getServerExtension(
return quic::none;
}
quic::ServerTransportParameters parameters;
folly::io::Cursor cursor(it->extension_data.get());
quic::Cursor cursor(it->extension_data.get());
decodeVarintParams(parameters.parameters, cursor);
return parameters;
}
@ -154,7 +154,7 @@ inline quic::Optional<quic::TicketTransportParameters> getTicketExtension(
return quic::none;
}
quic::TicketTransportParameters parameters;
folly::io::Cursor cursor(it->extension_data.get());
quic::Cursor cursor(it->extension_data.get());
decodeVarintParams(parameters.parameters, cursor);
return parameters;
}

View File

@ -19,7 +19,7 @@ Optional<uint64_t> getIntegerParameter(
if (it == parameters.end()) {
return none;
}
auto parameterCursor = folly::io::Cursor(it->value.get());
auto parameterCursor = Cursor(it->value.get());
auto parameter = decodeQuicInteger(parameterCursor);
if (!parameter) {
throw QuicTransportException(
@ -39,7 +39,7 @@ Optional<ConnectionId> getConnIdParameter(
}
auto value = it->value->clone();
folly::io::Cursor cursor(value.get());
Cursor cursor(value.get());
// Constructor may throw an exception if the input is invalid.
return ConnectionId(cursor, value->length());

View File

@ -186,7 +186,7 @@ void TakeoverPacketHandler::processForwardedPacket(
// First we decode the actual client and time from the packet
// and send it to the worker_ to handle it properly
folly::io::Cursor cursor(data.get());
Cursor cursor(data.get());
if (!cursor.canAdvance(sizeof(TakeoverProtocolVersion))) {
VLOG(4) << "Cannot read takeover protocol version. Dropping.";
return;

View File

@ -443,7 +443,7 @@ void QuicServerWorker::handleNetworkData(
try {
// check error conditions for packet drop & early return
folly::io::Cursor cursor(udpPacket.buf.front());
Cursor cursor(udpPacket.buf.front());
if (shutdown_) {
VLOG(4) << "Packet received after shutdown, dropping";
packetDropReason = PacketDropReason::SERVER_SHUTDOWN;
@ -945,7 +945,7 @@ void QuicServerWorker::dispatchPacketData(
// If there is a token present, decrypt it (could be either a retry
// token or a new token)
folly::io::Cursor cursor(networkData.getPackets().front().buf.front());
Cursor cursor(networkData.getPackets().front().buf.front());
auto maybeEncryptedToken = maybeGetEncryptedToken(cursor);
bool hasTokenSecret = transportSettings_.retryTokenSecret.hasValue();
@ -1032,8 +1032,7 @@ void QuicServerWorker::sendResetPacket(
QUIC_STATS(statsCallback_, onStatelessReset);
}
Optional<std::string> QuicServerWorker::maybeGetEncryptedToken(
folly::io::Cursor& cursor) {
Optional<std::string> QuicServerWorker::maybeGetEncryptedToken(Cursor& cursor) {
// Move cursor to the byte right after the initial byte
if (!cursor.canAdvance(1)) {
return none;
@ -1146,7 +1145,7 @@ void QuicServerWorker::sendRetryPacket(
FizzRetryIntegrityTagGenerator fizzRetryIntegrityTagGenerator;
auto integrityTagBuf = fizzRetryIntegrityTagGenerator.getRetryIntegrityTag(
QuicVersion::MVFST_INVALID, pseudoRetryPacketBuf.get());
folly::io::Cursor cursor{integrityTagBuf.get()};
Cursor cursor{integrityTagBuf.get()};
RetryPacket::IntegrityTagType integrityTag = {0};
cursor.pull(integrityTag.data(), integrityTag.size());

View File

@ -540,7 +540,7 @@ class QuicServerWorker : public FollyAsyncUDPSocketAlias::ReadCallback,
/**
* Tries to get the encrypted retry token from a client initial packet
*/
Optional<std::string> maybeGetEncryptedToken(folly::io::Cursor& cursor);
Optional<std::string> maybeGetEncryptedToken(Cursor& cursor);
bool validRetryToken(
std::string& encryptedToken,

View File

@ -826,7 +826,7 @@ folly::Expected<folly::Unit, QuicError> onServerReadDataFromOpen(
bool firstPacketFromPeer = false;
if (!conn.readCodec) {
firstPacketFromPeer = true;
folly::io::Cursor cursor(readData.udpPacket.buf.front());
Cursor cursor(readData.udpPacket.buf.front());
auto initialByte = cursor.readBE<uint8_t>();
auto parsedLongHeader = parseLongHeaderInvariant(initialByte, cursor);
if (!parsedLongHeader) {

View File

@ -1910,7 +1910,7 @@ void QuicServerWorkerTakeoverTest::testPacketForwarding(
// the writtenData contains actual client address + time of ack + data
EXPECT_FALSE(eq(*data, *writtenData));
// extract and verify the encoded client address
folly::io::Cursor cursor(writtenData.get());
Cursor cursor(writtenData.get());
uint32_t protocotVersion = (cursor.readBE<uint32_t>());
EXPECT_EQ(protocotVersion, 0x0000001);
uint16_t addrLen = (cursor.readBE<uint16_t>());