mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
remove the LongHeader field from the wire.Header
This commit is contained in:
parent
aca052dc7c
commit
86edf7fd4b
23 changed files with 154 additions and 363 deletions
|
@ -6,9 +6,6 @@ import (
|
|||
|
||||
// PacketTypeFromHeader determines the packet type from a *wire.Header.
|
||||
func PacketTypeFromHeader(hdr *Header) PacketType {
|
||||
if !hdr.IsLongHeader {
|
||||
return PacketType1RTT
|
||||
}
|
||||
if hdr.Version == 0 {
|
||||
return PacketTypeVersionNegotiation
|
||||
}
|
||||
|
|
|
@ -12,49 +12,38 @@ var _ = Describe("Packet Header", func() {
|
|||
Context("determining the packet type from the header", func() {
|
||||
It("recognizes Initial packets", func() {
|
||||
Expect(PacketTypeFromHeader(&wire.Header{
|
||||
IsLongHeader: true,
|
||||
Type: protocol.PacketTypeInitial,
|
||||
Version: protocol.VersionTLS,
|
||||
Type: protocol.PacketTypeInitial,
|
||||
Version: protocol.VersionTLS,
|
||||
})).To(Equal(PacketTypeInitial))
|
||||
})
|
||||
|
||||
It("recognizes Handshake packets", func() {
|
||||
Expect(PacketTypeFromHeader(&wire.Header{
|
||||
IsLongHeader: true,
|
||||
Type: protocol.PacketTypeHandshake,
|
||||
Version: protocol.VersionTLS,
|
||||
Type: protocol.PacketTypeHandshake,
|
||||
Version: protocol.VersionTLS,
|
||||
})).To(Equal(PacketTypeHandshake))
|
||||
})
|
||||
|
||||
It("recognizes Retry packets", func() {
|
||||
Expect(PacketTypeFromHeader(&wire.Header{
|
||||
IsLongHeader: true,
|
||||
Type: protocol.PacketTypeRetry,
|
||||
Version: protocol.VersionTLS,
|
||||
Type: protocol.PacketTypeRetry,
|
||||
Version: protocol.VersionTLS,
|
||||
})).To(Equal(PacketTypeRetry))
|
||||
})
|
||||
|
||||
It("recognizes 0-RTT packets", func() {
|
||||
Expect(PacketTypeFromHeader(&wire.Header{
|
||||
IsLongHeader: true,
|
||||
Type: protocol.PacketType0RTT,
|
||||
Version: protocol.VersionTLS,
|
||||
Type: protocol.PacketType0RTT,
|
||||
Version: protocol.VersionTLS,
|
||||
})).To(Equal(PacketType0RTT))
|
||||
})
|
||||
|
||||
It("recognizes Version Negotiation packets", func() {
|
||||
Expect(PacketTypeFromHeader(&wire.Header{IsLongHeader: true})).To(Equal(PacketTypeVersionNegotiation))
|
||||
})
|
||||
|
||||
It("recognizes 1-RTT packets", func() {
|
||||
Expect(PacketTypeFromHeader(&wire.Header{})).To(Equal(PacketType1RTT))
|
||||
Expect(PacketTypeFromHeader(&wire.Header{})).To(Equal(PacketTypeVersionNegotiation))
|
||||
})
|
||||
|
||||
It("handles unrecognized packet types", func() {
|
||||
Expect(PacketTypeFromHeader(&wire.Header{
|
||||
IsLongHeader: true,
|
||||
Version: protocol.VersionTLS,
|
||||
})).To(Equal(PacketTypeNotDetermined))
|
||||
Expect(PacketTypeFromHeader(&wire.Header{Version: protocol.VersionTLS})).To(Equal(PacketTypeNotDetermined))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue