Interface PacketHeader
- All Known Subinterfaces:
PacketHeader.Numbered
- All Known Implementing Classes:
PacketHeader.Handshake,PacketHeader.Initial,PacketHeader.Retry,PacketHeader.Short,PacketHeader.VersionNegotiation,PacketHeader.ZeroRtt
public sealed interface PacketHeader
permits PacketHeader.Numbered, PacketHeader.Retry, PacketHeader.VersionNegotiation
A decoded QUIC packet header (RFC 9000 section 17), or one to encode. Protected packets carry a
full packet number and the length it is sent with; Retry and Version Negotiation packets have
none.
encode(ByteBuffer) writes the header with the packet number unprotected and, for
long headers, a two-byte Length placeholder; PacketProtection.protect(java.nio.ByteBuffer, io.github.mahmoudimus.quic.packet.HeaderLayout, int, long, io.github.mahmoudimus.quic.crypto.DirectionalKeys) fills it in.
Records are immutable; byte-array components are copied in and out.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordA Handshake packet header (RFC 9000 section 17.2.4).static final recordAn Initial packet header (RFC 9000 section 17.2.2).static interfaceA header of a protected packet, with a packet number.static final recordA Retry packet (RFC 9000 section 17.2.5): the whole packet, since it has no payload beyond the token and the integrity tag.static final recordA short (1-RTT) packet header (RFC 9000 section 17.3.1).static final recordA Version Negotiation packet (RFC 9000 section 17.2.1): the whole packet.static final recordA 0-RTT packet header (RFC 9000 section 17.2.3). -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe Fixed Bit, set in every version 1 and 2 packet unless greased (RFC 9287).static final intThe Key Phase bit of short headers.static final intThe Header Form bit, set in long headers.static final intThe reserved bits of long headers, zero once header protection is removed.static final intThe reserved bits of short headers, zero once header protection is removed.static final intThe latency spin bit of short headers. -
Method Summary
Modifier and TypeMethodDescriptionThe Destination Connection ID.encode(ByteBuffer out) Writes the header at the buffer's position.type()The packet type.
-
Field Details
-
LONG_HEADER_FORM
static final int LONG_HEADER_FORMThe Header Form bit, set in long headers.- See Also:
-
FIXED_BIT
static final int FIXED_BITThe Fixed Bit, set in every version 1 and 2 packet unless greased (RFC 9287).- See Also:
-
SPIN_BIT
static final int SPIN_BITThe latency spin bit of short headers.- See Also:
-
LONG_RESERVED_BITS
static final int LONG_RESERVED_BITSThe reserved bits of long headers, zero once header protection is removed.- See Also:
-
SHORT_RESERVED_BITS
static final int SHORT_RESERVED_BITSThe reserved bits of short headers, zero once header protection is removed.- See Also:
-
KEY_PHASE_BIT
static final int KEY_PHASE_BITThe Key Phase bit of short headers.- See Also:
-
-
Method Details
-
type
PacketType type()The packet type.- Returns:
- the type
-
destinationId
ConnectionId destinationId()The Destination Connection ID.- Returns:
- the connection ID
-
encode
Writes the header at the buffer's position.- Parameters:
out- the buffer- Returns:
- where the fields landed
- Throws:
BufferOverflowException- if the buffer has too little room
-