rename InferPacketNumber to DecodePacketNumber

That's how it's called in the draft.
This commit is contained in:
Marten Seemann 2018-11-29 12:03:19 +07:00
parent a009217ee4
commit c06a0ca037
3 changed files with 13 additions and 13 deletions

View file

@ -16,8 +16,8 @@ const (
PacketNumberLen4 PacketNumberLen = 4 PacketNumberLen4 PacketNumberLen = 4
) )
// InferPacketNumber calculates the packet number based on the received packet number, its length and the last seen packet number // DecodePacketNumber calculates the packet number based on the received packet number, its length and the last seen packet number
func InferPacketNumber( func DecodePacketNumber(
packetNumberLength PacketNumberLen, packetNumberLength PacketNumberLen,
lastPacketNumber PacketNumber, lastPacketNumber PacketNumber,
wirePacketNumber PacketNumber, wirePacketNumber PacketNumber,

View file

@ -11,7 +11,7 @@ import (
// Tests taken and extended from chrome // Tests taken and extended from chrome
var _ = Describe("packet number calculation", func() { var _ = Describe("packet number calculation", func() {
It("works with the example from the draft", func() { It("works with the example from the draft", func() {
Expect(InferPacketNumber(PacketNumberLen2, 0xa82f30ea, 0x9b32)).To(Equal(PacketNumber(0xa82f9b32))) Expect(DecodePacketNumber(PacketNumberLen2, 0xa82f30ea, 0x9b32)).To(Equal(PacketNumber(0xa82f9b32)))
}) })
getEpoch := func(len PacketNumberLen) uint64 { getEpoch := func(len PacketNumberLen) uint64 {
@ -25,7 +25,7 @@ var _ = Describe("packet number calculation", func() {
epoch := getEpoch(length) epoch := getEpoch(length)
epochMask := epoch - 1 epochMask := epoch - 1
wirePacketNumber := expected & epochMask wirePacketNumber := expected & epochMask
Expect(InferPacketNumber(length, PacketNumber(last), PacketNumber(wirePacketNumber))).To(Equal(PacketNumber(expected))) Expect(DecodePacketNumber(length, PacketNumber(last), PacketNumber(wirePacketNumber))).To(Equal(PacketNumber(expected)))
} }
for _, l := range []PacketNumberLen{PacketNumberLen1, PacketNumberLen2, PacketNumberLen4} { for _, l := range []PacketNumberLen{PacketNumberLen1, PacketNumberLen2, PacketNumberLen4} {
@ -167,8 +167,8 @@ var _ = Describe("packet number calculation", func() {
length := GetPacketNumberLengthForHeader(packetNumber, leastUnacked) length := GetPacketNumberLengthForHeader(packetNumber, leastUnacked)
wirePacketNumber := (uint64(packetNumber) << (64 - length*8)) >> (64 - length*8) wirePacketNumber := (uint64(packetNumber) << (64 - length*8)) >> (64 - length*8)
inferedPacketNumber := InferPacketNumber(length, leastUnacked, PacketNumber(wirePacketNumber)) decodedPacketNumber := DecodePacketNumber(length, leastUnacked, PacketNumber(wirePacketNumber))
Expect(inferedPacketNumber).To(Equal(packetNumber)) Expect(decodedPacketNumber).To(Equal(packetNumber))
} }
}) })
@ -180,8 +180,8 @@ var _ = Describe("packet number calculation", func() {
epochMask := getEpoch(length) - 1 epochMask := getEpoch(length) - 1
wirePacketNumber := uint64(packetNumber) & epochMask wirePacketNumber := uint64(packetNumber) & epochMask
inferedPacketNumber := InferPacketNumber(length, leastUnacked, PacketNumber(wirePacketNumber)) decodedPacketNumber := DecodePacketNumber(length, leastUnacked, PacketNumber(wirePacketNumber))
Expect(inferedPacketNumber).To(Equal(packetNumber)) Expect(decodedPacketNumber).To(Equal(packetNumber))
} }
}) })
@ -194,8 +194,8 @@ var _ = Describe("packet number calculation", func() {
epochMask := getEpoch(length) - 1 epochMask := getEpoch(length) - 1
wirePacketNumber := uint64(packetNumber) & epochMask wirePacketNumber := uint64(packetNumber) & epochMask
inferedPacketNumber := InferPacketNumber(length, leastUnacked, PacketNumber(wirePacketNumber)) decodedPacketNumber := DecodePacketNumber(length, leastUnacked, PacketNumber(wirePacketNumber))
Expect(inferedPacketNumber).To(Equal(packetNumber)) Expect(decodedPacketNumber).To(Equal(packetNumber))
increment = getEpoch(length) / 8 increment = getEpoch(length) / 8
} }
@ -208,8 +208,8 @@ var _ = Describe("packet number calculation", func() {
length := GetPacketNumberLengthForHeader(packetNumber, leastUnacked) length := GetPacketNumberLengthForHeader(packetNumber, leastUnacked)
wirePacketNumber := (uint64(packetNumber) << (64 - length*8)) >> (64 - length*8) wirePacketNumber := (uint64(packetNumber) << (64 - length*8)) >> (64 - length*8)
inferedPacketNumber := InferPacketNumber(length, leastUnacked, PacketNumber(wirePacketNumber)) decodedPacketNumber := DecodePacketNumber(length, leastUnacked, PacketNumber(wirePacketNumber))
Expect(inferedPacketNumber).To(Equal(packetNumber)) Expect(decodedPacketNumber).To(Equal(packetNumber))
} }
}) })
}) })

View file

@ -505,7 +505,7 @@ func (s *session) handlePacketImpl(p *receivedPacket) error {
} }
// Calculate packet number // Calculate packet number
hdr.PacketNumber = protocol.InferPacketNumber( hdr.PacketNumber = protocol.DecodePacketNumber(
hdr.PacketNumberLen, hdr.PacketNumberLen,
s.largestRcvdPacketNumber, s.largestRcvdPacketNumber,
hdr.PacketNumber, hdr.PacketNumber,