mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-05 05:07:36 +03:00
remove unused function GetPacketNumberLength
This commit is contained in:
parent
119286b05a
commit
d495b4bada
2 changed files with 5 additions and 37 deletions
|
@ -79,17 +79,3 @@ func GetPacketNumberLengthForHeader(packetNumber, leastUnacked PacketNumber) Pac
|
|||
}
|
||||
return PacketNumberLen4
|
||||
}
|
||||
|
||||
// GetPacketNumberLength gets the minimum length needed to fully represent the packet number
|
||||
func GetPacketNumberLength(packetNumber PacketNumber) PacketNumberLen {
|
||||
if packetNumber < (1 << (uint8(PacketNumberLen1) * 8)) {
|
||||
return PacketNumberLen1
|
||||
}
|
||||
if packetNumber < (1 << (uint8(PacketNumberLen2) * 8)) {
|
||||
return PacketNumberLen2
|
||||
}
|
||||
if packetNumber < (1 << (uint8(PacketNumberLen3) * 8)) {
|
||||
return PacketNumberLen3
|
||||
}
|
||||
return PacketNumberLen4
|
||||
}
|
||||
|
|
|
@ -17,6 +17,11 @@ var _ = Describe("packet number calculation", func() {
|
|||
Expect(DecodePacketNumber(PacketNumberLen2, 0xa82f30ea, 0x9b32)).To(Equal(PacketNumber(0xa82f9b32)))
|
||||
})
|
||||
|
||||
It("works with the examples from the draft", func() {
|
||||
Expect(GetPacketNumberLengthForHeader(0xac5c02, 0xabe8bc)).To(Equal(PacketNumberLen2))
|
||||
Expect(GetPacketNumberLengthForHeader(0xace8fe, 0xabe8bc)).To(Equal(PacketNumberLen3))
|
||||
})
|
||||
|
||||
getEpoch := func(len PacketNumberLen) uint64 {
|
||||
if len > 4 {
|
||||
Fail("invalid packet number len")
|
||||
|
@ -196,27 +201,4 @@ var _ = Describe("packet number calculation", func() {
|
|||
})
|
||||
})
|
||||
}
|
||||
|
||||
Context("determining the minimum length of a packet number", func() {
|
||||
It("works with the examples from the draft", func() {
|
||||
Expect(GetPacketNumberLengthForHeader(0xac5c02, 0xabe8bc)).To(Equal(PacketNumberLen2))
|
||||
Expect(GetPacketNumberLengthForHeader(0xace8fe, 0xabe8bc)).To(Equal(PacketNumberLen3))
|
||||
})
|
||||
|
||||
It("1 byte", func() {
|
||||
Expect(GetPacketNumberLength(0xFF)).To(Equal(PacketNumberLen1))
|
||||
})
|
||||
|
||||
It("2 byte", func() {
|
||||
Expect(GetPacketNumberLength(0xFFFF)).To(Equal(PacketNumberLen2))
|
||||
})
|
||||
|
||||
It("3 byte", func() {
|
||||
Expect(GetPacketNumberLength(0xFFFFFF)).To(Equal(PacketNumberLen3))
|
||||
})
|
||||
|
||||
It("4 byte", func() {
|
||||
Expect(GetPacketNumberLength(0xFFFFFFFF)).To(Equal(PacketNumberLen4))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue