mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-06 13:47:35 +03:00
fix reading of multiple-byte missingPacketSequenceNumberDeltas in AckFrame parsing
This commit is contained in:
parent
daa0fe86bd
commit
b084faff88
2 changed files with 17 additions and 6 deletions
|
@ -64,7 +64,6 @@ func ParseAckFrame(r *bytes.Reader) (*AckFrame, error) {
|
|||
if missingSequenceNumberDeltaLen == 0 {
|
||||
missingSequenceNumberDeltaLen = 1
|
||||
}
|
||||
_ = missingSequenceNumberDeltaLen
|
||||
|
||||
frame.Entropy, err = r.ReadByte()
|
||||
if err != nil {
|
||||
|
@ -120,28 +119,28 @@ func ParseAckFrame(r *bytes.Reader) (*AckFrame, error) {
|
|||
}
|
||||
|
||||
for i := uint8(0); i < numRanges; i++ {
|
||||
missingPacketSequenceNumberDeltaByte, err := r.ReadByte()
|
||||
missingPacketSequenceNumberDelta, err := utils.ReadUintN(r, missingSequenceNumberDeltaLen)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
missingPacketSequenceNumberDelta := uint64(missingPacketSequenceNumberDeltaByte)
|
||||
|
||||
rangeLength, err := utils.ReadUintN(r, largestObservedLen)
|
||||
rangeLengthByte, err := r.ReadByte()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rangeLength := uint8(rangeLengthByte)
|
||||
|
||||
nackRange := ackhandler.NackRange{
|
||||
Length: uint8(rangeLength + 1),
|
||||
}
|
||||
if i == 0 {
|
||||
nackRange.FirstPacketNumber = frame.LargestObserved - protocol.PacketNumber(missingPacketSequenceNumberDelta+rangeLength)
|
||||
nackRange.FirstPacketNumber = frame.LargestObserved - protocol.PacketNumber(missingPacketSequenceNumberDelta+uint64(rangeLength))
|
||||
} else {
|
||||
if missingPacketSequenceNumberDelta == 0 {
|
||||
return nil, errors.New("ACK frame: Continues NACK ranges not yet implemented.")
|
||||
}
|
||||
lastNackRange := frame.NackRanges[len(frame.NackRanges)-1]
|
||||
nackRange.FirstPacketNumber = lastNackRange.FirstPacketNumber - protocol.PacketNumber(missingPacketSequenceNumberDelta+rangeLength) - 1
|
||||
nackRange.FirstPacketNumber = lastNackRange.FirstPacketNumber - protocol.PacketNumber(missingPacketSequenceNumberDelta+uint64(rangeLength)) - 1
|
||||
}
|
||||
frame.NackRanges = append(frame.NackRanges, &nackRange)
|
||||
}
|
||||
|
|
|
@ -46,6 +46,18 @@ var _ = Describe("AckFrame", func() {
|
|||
Expect(frame.NackRanges[0].Length).To(Equal(uint8(2)))
|
||||
})
|
||||
|
||||
It("parses a frame containing one NACK range with a 48 bit missingPacketSequenceNumberDelta", func() {
|
||||
b := bytes.NewReader([]byte{(0x4C | 0x20 | 0x03), 0x08, 0x37, 0x13, 0xAD, 0xFB, 0xCA, 0xDE, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x1, 0xFE, 0xCA, 0xEF, 0xBE, 0xAD, 0xDE, 0x3})
|
||||
frame, err := ParseAckFrame(b)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(0xDECAFBAD1337)))
|
||||
Expect(frame.HasNACK()).To(Equal(true))
|
||||
Expect(len(frame.NackRanges)).To(Equal(1))
|
||||
// ToDo: check NACK range
|
||||
Expect(frame.NackRanges[0].Length).To(Equal(uint8(4)))
|
||||
Expect(b.Len()).To(Equal(0))
|
||||
})
|
||||
|
||||
It("parses a frame containing multiple NACK ranges", func() {
|
||||
b := bytes.NewReader([]byte{0x60, 0x2, 0xf, 0xb8, 0x1, 0x1, 0x0, 0xe5, 0x58, 0x4, 0x0, 0x3, 0x1, 0x6, 0x1, 0x2, 0x1, 0x0})
|
||||
frame, err := ParseAckFrame(b)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue