Home / Class/ QuicHeaderParser Class — netty Architecture

QuicHeaderParser Class — netty Architecture

Architecture documentation for the QuicHeaderParser class in QuicHeaderParser.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  c7e41129_a960_2079_d47e_46ceea19e35c["QuicHeaderParser"]
  48dc0c48_28d2_f3d9_6142_f65005c57f3a["QuicHeaderParser.java"]
  c7e41129_a960_2079_d47e_46ceea19e35c -->|defined in| 48dc0c48_28d2_f3d9_6142_f65005c57f3a
  9f3cdbae_99c6_3315_e117_723a0f020316["QuicHeaderParser()"]
  c7e41129_a960_2079_d47e_46ceea19e35c -->|method| 9f3cdbae_99c6_3315_e117_723a0f020316
  0e10f544_a9e9_2c2e_d104_738255aadd1a["close()"]
  c7e41129_a960_2079_d47e_46ceea19e35c -->|method| 0e10f544_a9e9_2c2e_d104_738255aadd1a
  96928b1e_d3a9_3b36_08ba_c16229544e5c["parse()"]
  c7e41129_a960_2079_d47e_46ceea19e35c -->|method| 96928b1e_d3a9_3b36_08ba_c16229544e5c
  a6a94183_4957_7959_5cc5_e6ae948d5910["checkCidLength()"]
  c7e41129_a960_2079_d47e_46ceea19e35c -->|method| a6a94183_4957_7959_5cc5_e6ae948d5910
  a4f94f0b_5587_d928_f3fc_be19cc9bcfc4["ByteBuf()"]
  c7e41129_a960_2079_d47e_46ceea19e35c -->|method| a4f94f0b_5587_d928_f3fc_be19cc9bcfc4
  bdcc5f06_cbd2_bf95_5f85_4a360e906221["QuicException()"]
  c7e41129_a960_2079_d47e_46ceea19e35c -->|method| bdcc5f06_cbd2_bf95_5f85_4a360e906221
  8c03fba7_750c_033c_0ce0_7bb5c59ba68a["checkReadable()"]
  c7e41129_a960_2079_d47e_46ceea19e35c -->|method| 8c03fba7_750c_033c_0ce0_7bb5c59ba68a
  5ae8919b_456e_6bed_711b_5be295e22b94["getVariableLengthInteger()"]
  c7e41129_a960_2079_d47e_46ceea19e35c -->|method| 5ae8919b_456e_6bed_711b_5be295e22b94
  401289e2_5203_16b5_e109_038634d7531b["numBytesForVariableLengthInteger()"]
  c7e41129_a960_2079_d47e_46ceea19e35c -->|method| 401289e2_5203_16b5_e109_038634d7531b
  7906aa5b_4749_3d37_c2c4_7b6e28fe9050["hasShortHeader()"]
  c7e41129_a960_2079_d47e_46ceea19e35c -->|method| 7906aa5b_4749_3d37_c2c4_7b6e28fe9050
  2c7eb64e_5146_6ce7_b36e_93201aef670d["QuicPacketType()"]
  c7e41129_a960_2079_d47e_46ceea19e35c -->|method| 2c7eb64e_5146_6ce7_b36e_93201aef670d

Relationship Graph

Source Code

codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicHeaderParser.java lines 34–287

public final class QuicHeaderParser implements AutoCloseable {
    // See https://datatracker.ietf.org/doc/rfc7714/
    private static final int AES_128_GCM_TAG_LENGTH = 16;

    private final int localConnectionIdLength;
    private boolean closed;

    public QuicHeaderParser(int localConnectionIdLength) {
        this.localConnectionIdLength = checkPositiveOrZero(localConnectionIdLength, "localConnectionIdLength");
    }

    @Override
    public void close() {
        if (!closed) {
            closed = true;
        }
    }

    /**
     * Parses a QUIC packet and extract the header values out of it. This method takes no ownership of the packet itself
     * which means the caller of this method is expected to call {@link ByteBuf#release()} once the packet is not needed
     * anymore.
     *
     * @param sender        the sender of the packet. This is directly passed to the {@link QuicHeaderProcessor} once
     *                      parsing was successful.
     * @param recipient     the recipient of the packet.This is directly passed to the {@link QuicHeaderProcessor} once
     *                      parsing was successful.
     * @param packet        raw QUIC packet itself. The ownership of the packet is not transferred. This is directly
     *                      passed to the {@link QuicHeaderProcessor} once parsing was successful.
     * @param callback      the {@link QuicHeaderProcessor} that is called once a QUIC packet could be parsed and all
     *                      the header values be extracted.
     * @throws Exception    thrown if we couldn't parse the header or if the {@link QuicHeaderProcessor} throws an
     *                      exception.
     */
    public void parse(InetSocketAddress sender, InetSocketAddress recipient, ByteBuf packet,
                      QuicHeaderProcessor callback) throws Exception {
        if (closed) {
            throw new IllegalStateException(QuicHeaderParser.class.getSimpleName() + " is already closed");
        }

        // See https://datatracker.ietf.org/doc/html/rfc9000#section-17
        int offset = 0;
        int readable = packet.readableBytes();

        checkReadable(offset, readable, Byte.BYTES);
        byte first = packet.getByte(offset);
        offset += Byte.BYTES;

        final QuicPacketType type;
        final long version;
        final ByteBuf dcid;
        final ByteBuf scid;
        final ByteBuf token;

        if (hasShortHeader(first)) {
            // See https://www.rfc-editor.org/rfc/rfc9000.html#section-17.3
            // 1-RTT Packet {
            //  Header Form (1) = 0,
            //  Fixed Bit (1) = 1,
            //  Spin Bit (1),
            //  Reserved Bits (2),
            //  Key Phase (1),
            //  Packet Number Length (2),
            //  Destination Connection ID (0..160),
            //  Packet Number (8..32),
            //  Packet Payload (8..),
            //}
            version = 0;
            type = QuicPacketType.SHORT;
            // Short packets have no source connection id and no token.
            scid = Unpooled.EMPTY_BUFFER;
            token = Unpooled.EMPTY_BUFFER;
            dcid = sliceCid(packet, offset, localConnectionIdLength);
        } else {
            // See https://www.rfc-editor.org/rfc/rfc9000.html#section-17.2
            // Long Header Packet {
            //  Header Form (1) = 1,
            //  Fixed Bit (1) = 1,
            //  Long Packet Type (2),
            //  Type-Specific Bits (4),
            //  Version (32),

Frequently Asked Questions

What is the QuicHeaderParser class?
QuicHeaderParser is a class in the netty codebase, defined in codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicHeaderParser.java.
Where is QuicHeaderParser defined?
QuicHeaderParser is defined in codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicHeaderParser.java at line 34.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free