github.com/sagernet/quic-go@v0.43.1-beta.1/logging/packet_header.go (about)

     1  package logging
     2  
     3  import (
     4  	"github.com/sagernet/quic-go/internal/protocol"
     5  )
     6  
     7  // PacketTypeFromHeader determines the packet type from a *wire.Header.
     8  func PacketTypeFromHeader(hdr *Header) PacketType {
     9  	if hdr.Version == 0 {
    10  		return PacketTypeVersionNegotiation
    11  	}
    12  	switch hdr.Type {
    13  	case protocol.PacketTypeInitial:
    14  		return PacketTypeInitial
    15  	case protocol.PacketTypeHandshake:
    16  		return PacketTypeHandshake
    17  	case protocol.PacketType0RTT:
    18  		return PacketType0RTT
    19  	case protocol.PacketTypeRetry:
    20  		return PacketTypeRetry
    21  	default:
    22  		return PacketTypeNotDetermined
    23  	}
    24  }