Enum Class PacketType

java.lang.Object
java.lang.Enum<PacketType>
io.github.mahmoudimus.quic.packet.PacketType
All Implemented Interfaces:
Serializable, Comparable<PacketType>, Constable

public enum PacketType extends Enum<PacketType>
The QUIC packet types (RFC 9000 section 17). Long header types carry two type bits whose values differ between version 1 and version 2.
  • Enum Constant Details

    • INITIAL

      public static final PacketType INITIAL
      Initial (long header), carrying the first CRYPTO data and an optional token.
    • ZERO_RTT

      public static final PacketType ZERO_RTT
      0-RTT (long header), early application data.
    • HANDSHAKE

      public static final PacketType HANDSHAKE
      Handshake (long header).
    • RETRY

      public static final PacketType RETRY
      Retry (long header), unprotected except for its integrity tag.
    • VERSION_NEGOTIATION

      public static final PacketType VERSION_NEGOTIATION
      Version Negotiation (long header with version 0), unprotected.
    • ONE_RTT

      public static final PacketType ONE_RTT
      1-RTT (short header).
  • Method Details

    • values

      public static PacketType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static PacketType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • level

      public EncryptionLevel level()
      The encryption level whose keys protect this packet type.
      Returns:
      the level, or null for Retry and Version Negotiation packets
    • isProtected

      public boolean isProtected()
      Whether the packet has header and payload protection and a packet number.
      Returns:
      false for Retry and Version Negotiation packets
    • isLongHeader

      public boolean isLongHeader()
      Whether the packet uses a long header.
      Returns:
      true for every type but ONE_RTT
    • longTypeBits

      public int longTypeBits(QuicVersion version)
      The two Long Packet Type bits of this type in a version.
      Parameters:
      version - the QUIC version
      Returns:
      0 to 3
      Throws:
      IllegalStateException - for ONE_RTT and VERSION_NEGOTIATION
    • fromLongTypeBits

      public static PacketType fromLongTypeBits(QuicVersion version, int bits)
      The long header type for two type bits in a version.
      Parameters:
      version - the QUIC version
      bits - the Long Packet Type bits, 0 to 3
      Returns:
      INITIAL, ZERO_RTT, HANDSHAKE or RETRY