move the PacketHeader struct from logging to qlog package

This commit is contained in:
Marten Seemann 2020-09-09 13:17:59 +07:00
parent bed802aee5
commit 704bd78445
2 changed files with 15 additions and 18 deletions

View file

@ -25,18 +25,3 @@ func PacketTypeFromHeader(hdr *Header) PacketType {
return PacketTypeNotDetermined
}
}
// PacketHeader is a QUIC packet header.
type PacketHeader struct {
PacketType PacketType
PacketNumber PacketNumber
PayloadLength ByteCount
// Size of the QUIC packet (QUIC header + payload).
// See https://github.com/quiclog/internet-drafts/issues/40.
PacketSize ByteCount
Version VersionNumber
SrcConnectionID ConnectionID
DestConnectionID ConnectionID
}

View file

@ -24,6 +24,21 @@ func getPacketTypeFromEncryptionLevel(encLevel protocol.EncryptionLevel) packetT
return packetType(t)
}
// PacketHeader is a QUIC packet header.
type packetHeader struct {
PacketType logging.PacketType
PacketNumber logging.PacketNumber
PayloadLength logging.ByteCount
// Size of the QUIC packet (QUIC header + payload).
// See https://github.com/quiclog/internet-drafts/issues/40.
PacketSize logging.ByteCount
Version logging.VersionNumber
SrcConnectionID logging.ConnectionID
DestConnectionID logging.ConnectionID
}
func transformHeader(hdr *wire.Header) *packetHeader {
return &packetHeader{
PacketType: logging.PacketTypeFromHeader(hdr),
@ -40,9 +55,6 @@ func transformExtendedHeader(hdr *wire.ExtendedHeader) *packetHeader {
return h
}
// We don't log the packet type as a part of the header yet, see https://github.com/quiclog/internet-drafts/issues/40.
type packetHeader logging.PacketHeader
func (h packetHeader) MarshalJSONObject(enc *gojay.Encoder) {
if h.PacketType != logging.PacketTypeRetry && h.PacketType != logging.PacketTypeVersionNegotiation {
enc.Int64Key("packet_number", int64(h.PacketNumber))