add a function to distinguish between long and short header packets (#3498)

This commit is contained in:
Marten Seemann 2022-08-11 16:35:01 +02:00 committed by GitHub
parent bebff462c8
commit 80fd1b57c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 11 deletions

View file

@ -390,7 +390,7 @@ func (h *packetHandlerMap) handlePacket(p *receivedPacket) {
return
}
}
if p.data[0]&0x80 == 0 {
if !wire.IsLongHeaderPacket(p.data[0]) {
go h.maybeSendStatelessReset(p, connID)
return
}
@ -433,7 +433,7 @@ func (h *packetHandlerMap) handlePacket(p *receivedPacket) {
func (h *packetHandlerMap) maybeHandleStatelessReset(data []byte) bool {
// stateless resets are always short header packets
if data[0]&0x80 != 0 {
if wire.IsLongHeaderPacket(data[0]) {
return false
}
if len(data) < 17 /* type byte + 16 bytes for the reset token */ {