APIdia Launch Partner
Top Description Fields Constructors Methods
jdk.internal.net.http.quic.frames

public abstract sealed Class QuicFrame

extends Object
permits AckFrame, DataBlockedFrame, ConnectionCloseFrame, CryptoFrame, HandshakeDoneFrame, MaxDataFrame, MaxStreamDataFrame, MaxStreamsFrame, NewConnectionIDFrame, NewTokenFrame, PaddingFrame, PathChallengeFrame, PathResponseFrame, PingFrame, ResetStreamFrame, RetireConnectionIDFrame, StreamsBlockedFrame, StreamDataBlockedFrame, StreamFrame, StopSendingFrame
Class Inheritance
Known Direct Subclasses
jdk.internal.net.http.quic.frames.ResetStreamFrame, jdk.internal.net.http.quic.frames.RetireConnectionIDFrame, jdk.internal.net.http.quic.frames.StopSendingFrame, jdk.internal.net.http.quic.frames.StreamDataBlockedFrame, jdk.internal.net.http.quic.frames.StreamFrame, jdk.internal.net.http.quic.frames.StreamsBlockedFrame, jdk.internal.net.http.quic.frames.AckFrame, jdk.internal.net.http.quic.frames.ConnectionCloseFrame, jdk.internal.net.http.quic.frames.CryptoFrame, jdk.internal.net.http.quic.frames.DataBlockedFrame, jdk.internal.net.http.quic.frames.HandshakeDoneFrame, jdk.internal.net.http.quic.frames.MaxDataFrame, jdk.internal.net.http.quic.frames.MaxStreamDataFrame, jdk.internal.net.http.quic.frames.MaxStreamsFrame, jdk.internal.net.http.quic.frames.NewConnectionIDFrame, jdk.internal.net.http.quic.frames.NewTokenFrame, jdk.internal.net.http.quic.frames.PaddingFrame, jdk.internal.net.http.quic.frames.PathChallengeFrame, jdk.internal.net.http.quic.frames.PathResponseFrame, jdk.internal.net.http.quic.frames.PingFrame
Imports
java.nio.ByteBuffer, jdk.internal.net.http.quic.packets.QuicPacket, jdk.internal.net.quic.QuicTransportErrors, .QuicTransportException, jdk.internal.net.http.quic.VariableLengthEncoder

A QUIC Frame
External Specification
https://www.rfc-editor.org/info/rfc9000

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
public static final int
public static final int
private final int
public static final int
public static final int
private static final int
public static final int
public static final int
public static final long
public static final int
public static final int
public static final int
PADDING

Frame types

public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
pack-priv
QuicFrame(int
the first byte of the frame, which encodes the frame type.
type
)

Concrete Frame types normally have two constructors which call this XXXFrame(ByteBuffer, int firstByte) which is called for incoming frames after reading the first byte to determine the type.

Method Summary

Modifier and TypeMethod and Description
public static QuicFrame
decode(ByteBuffer buffer)

decode given ByteBuffer and return a QUICFrame

protected final long
protected final int
public abstract void
encode(ByteBuffer buffer)

Encode this QUIC Frame into given ByteBuffer

protected static void
encodeVLField(ByteBuffer buffer, long val, String name)

public static Class<? extends QuicFrame>
frameClassOf(int frameType)

public int
frameType()

The type of this frame, ie.

public static int
frameTypeOf(Class<? extends QuicFrame> frameClass)

public long

Returns:

the type field that was / should be encoded
getTypeField
()

Returns the type field that was / should be encoded.

protected static int
public boolean

Returns:

true if this frame is ACK-eliciting
isAckEliciting
()

Returns true if this frame is ACK-eliciting.

public boolean

Returns:

true if the frame can be embedded in a packet of that type
isValidIn
(QuicPacket.PacketType
the packet type
packetType
)

Tells whether this particular frame is valid in the given packet type.

private static int
maskType(int type)

depending on the frame type, additional bits can be encoded in frameType().

protected static void
putByteBuffer(ByteBuffer dest, ByteBuffer src)

Writes src to dest, preserving position in src

protected static int
requireVLRange(int val, String message)

protected static long
requireVLRange(long val, String fieldName)

public abstract int

Returns:

the minimum number of bytes needed to encode this frame
size
()

Returns the minimum number of bytes needed to encode this frame.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

protected static void
validateRemainingLength(ByteBuffer
source buffer
buffer
,
int
minimum number of bytes required
expected
,
long
frame type to include in exception
type
)

Throws a QuicTransportException if the given buffer does not have enough bytes to finish decoding the frame

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

ACKback to summary
public static final int ACK
CONNECTION_CLOSEback to summary
public static final int CONNECTION_CLOSE
CRYPTOback to summary
public static final int CRYPTO
DATA_BLOCKEDback to summary
public static final int DATA_BLOCKED
frameTypeback to summary
private final int frameType
HANDSHAKE_DONEback to summary
public static final int HANDSHAKE_DONE
MAX_DATAback to summary
public static final int MAX_DATA
MAX_KNOWN_FRAME_TYPEback to summary
private static final int MAX_KNOWN_FRAME_TYPE
MAX_STREAM_DATAback to summary
public static final int MAX_STREAM_DATA
MAX_STREAMSback to summary
public static final int MAX_STREAMS
MAX_VL_INTEGERback to summary
public static final long MAX_VL_INTEGER
NEW_CONNECTION_IDback to summary
public static final int NEW_CONNECTION_ID
NEW_TOKENback to summary
public static final int NEW_TOKEN
PADDINGback to summary
public static final int PADDING

Frame types

PATH_CHALLENGEback to summary
public static final int PATH_CHALLENGE
PATH_RESPONSEback to summary
public static final int PATH_RESPONSE
PINGback to summary
public static final int PING
RESET_STREAMback to summary
public static final int RESET_STREAM
RETIRE_CONNECTION_IDback to summary
public static final int RETIRE_CONNECTION_ID
STOP_SENDINGback to summary
public static final int STOP_SENDING
STREAMback to summary
public static final int STREAM
STREAM_DATA_BLOCKEDback to summary
public static final int STREAM_DATA_BLOCKED
STREAMS_BLOCKEDback to summary
public static final int STREAMS_BLOCKED

Constructor Detail

QuicFrameback to summary
pack-priv QuicFrame(int type)

Concrete Frame types normally have two constructors which call this XXXFrame(ByteBuffer, int firstByte) which is called for incoming frames after reading the first byte to determine the type. The firstByte is also supplied to the constructor because it can contain additional state information XXXFrame(...) which is called to instantiate outgoing frames

Parameters
type:int

the first byte of the frame, which encodes the frame type.

Method Detail

decodeback to summary
public static QuicFrame decode(ByteBuffer buffer) throws QuicTransportException

decode given ByteBuffer and return a QUICFrame

decodeVLFieldback to summary
protected final long decodeVLField(ByteBuffer buffer, String name) throws QuicTransportException
decodeVLFieldAsIntback to summary
protected final int decodeVLFieldAsInt(ByteBuffer buffer, String name) throws QuicTransportException
encodeback to summary
public abstract void encode(ByteBuffer buffer)

Encode this QUIC Frame into given ByteBuffer

encodeVLFieldback to summary
protected static void encodeVLField(ByteBuffer buffer, long val, String name)
frameClassOfback to summary
public static Class<? extends QuicFrame> frameClassOf(int frameType)
frameTypeback to summary
public int frameType()

The type of this frame, ie. one of values above, which means it excludes the additional information that is encoded into the first field of some QUIC frames. That additional info has to be maintained by the sub class and used by its encode() method to generate the first field for outgoing frames. see maskType() below

frameTypeOfback to summary
public static int frameTypeOf(Class<? extends QuicFrame> frameClass)
getTypeFieldback to summary
public long getTypeField()

Returns the type field that was / should be encoded. This is the frame type with possibly some additional bits set, depending on the frame.

Implementation Specification

The default implementation of this method is to return frameType().

Returns:long

the type field that was / should be encoded

getVLFieldLengthForback to summary
protected static int getVLFieldLengthFor(long val)
isAckElicitingback to summary
public boolean isAckEliciting()

Returns true if this frame is ACK-eliciting. A frame is ACK-eliciting if it is anything other than QuicFrame#ACK, QuicFrame#PADDING or QuicFrame#CONNECTION_CLOSE (or its variant).

Returns:boolean

true if this frame is ACK-eliciting

isValidInback to summary
public boolean isValidIn(QuicPacket.PacketType packetType)

Tells whether this particular frame is valid in the given packet type.

From RFC 9000, section 12.5. Frames and Number Spaces:

Some frames are prohibited in different packet number space The rules here generalize those of TLS, in that frames associated with establishing the connection can usually appear in packets in any packet number space, whereas those associated with transferring data can only appear in the application data packet number space:
  • PADDING, PING, and CRYPTO frames MAY appear in any packet number space.
  • CONNECTION_CLOSE frames signaling errors at the QUIC layer (type 0x1c) MAY appear in any packet number space.
  • CONNECTION_CLOSE frames signaling application errors (type 0x1d) MUST only appear in the application data packet number space.
  • ACK frames MAY appear in any packet number space but can only acknowledge packets that appeared in that packet number space. However, as noted below, 0-RTT packets cannot contain ACK frames.
  • All other frame types MUST only be sent in the application data packet number space.
Note that it is not possible to send the following frames in 0-RTT packets for various reasons: ACK, CRYPTO, HANDSHAKE_DONE, NEW_TOKEN, PATH_RESPONSE, and RETIRE_CONNECTION_ID. A server MAY treat receipt of these frames in 0-RTT packets as a connection error of type PROTOCOL_VIOLATION.
Parameters
packetType:QuicPacket.PacketType

the packet type

Returns:boolean

true if the frame can be embedded in a packet of that type

maskTypeback to summary
private static int maskType(int type)

depending on the frame type, additional bits can be encoded in frameType(). This masks them out to return a unique value for each frame type.

putByteBufferback to summary
protected static void putByteBuffer(ByteBuffer dest, ByteBuffer src)

Writes src to dest, preserving position in src

requireVLRangeback to summary
protected static int requireVLRange(int val, String message)
requireVLRangeback to summary
protected static long requireVLRange(long val, String fieldName)
sizeback to summary
public abstract int size()

Returns the minimum number of bytes needed to encode this frame.

Returns:int

the minimum number of bytes needed to encode this frame

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
validateRemainingLengthback to summary
protected static void validateRemainingLength(ByteBuffer buffer, int expected, long type) throws QuicTransportException

Throws a QuicTransportException if the given buffer does not have enough bytes to finish decoding the frame

Parameters
buffer:ByteBuffer

source buffer

expected:int

minimum number of bytes required

type:long

frame type to include in exception

Exceptions
QuicTransportException:
if the buffer is shorter than expected