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 Classes
    Modifier and Type
    Interface
    Description
    static final record 
    A Handshake packet header (RFC 9000 section 17.2.4).
    static final record 
    An Initial packet header (RFC 9000 section 17.2.2).
    static interface 
    A header of a protected packet, with a packet number.
    static final record 
    A 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 record 
    A short (1-RTT) packet header (RFC 9000 section 17.3.1).
    static final record 
    A Version Negotiation packet (RFC 9000 section 17.2.1): the whole packet.
    static final record 
    A 0-RTT packet header (RFC 9000 section 17.2.3).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The Fixed Bit, set in every version 1 and 2 packet unless greased (RFC 9287).
    static final int
    The Key Phase bit of short headers.
    static final int
    The Header Form bit, set in long headers.
    static final int
    The reserved bits of long headers, zero once header protection is removed.
    static final int
    The reserved bits of short headers, zero once header protection is removed.
    static final int
    The latency spin bit of short headers.
  • Method Summary

    Modifier and Type
    Method
    Description
    The Destination Connection ID.
    Writes the header at the buffer's position.
    The packet type.
  • Field Details

    • LONG_HEADER_FORM

      static final int LONG_HEADER_FORM
      The Header Form bit, set in long headers.
      See Also:
    • FIXED_BIT

      static final int FIXED_BIT
      The Fixed Bit, set in every version 1 and 2 packet unless greased (RFC 9287).
      See Also:
    • SPIN_BIT

      static final int SPIN_BIT
      The latency spin bit of short headers.
      See Also:
    • LONG_RESERVED_BITS

      static final int LONG_RESERVED_BITS
      The reserved bits of long headers, zero once header protection is removed.
      See Also:
    • SHORT_RESERVED_BITS

      static final int SHORT_RESERVED_BITS
      The reserved bits of short headers, zero once header protection is removed.
      See Also:
    • KEY_PHASE_BIT

      static final int KEY_PHASE_BIT
      The 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

      HeaderLayout encode(ByteBuffer out)
      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