Home / Function/ parse() — netty Function Reference

parse() — netty Function Reference

Architecture documentation for the parse() function in QuicHeaderParser.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  96928b1e_d3a9_3b36_08ba_c16229544e5c["parse()"]
  c7e41129_a960_2079_d47e_46ceea19e35c["QuicHeaderParser"]
  96928b1e_d3a9_3b36_08ba_c16229544e5c -->|defined in| c7e41129_a960_2079_d47e_46ceea19e35c
  8c03fba7_750c_033c_0ce0_7bb5c59ba68a["checkReadable()"]
  96928b1e_d3a9_3b36_08ba_c16229544e5c -->|calls| 8c03fba7_750c_033c_0ce0_7bb5c59ba68a
  7906aa5b_4749_3d37_c2c4_7b6e28fe9050["hasShortHeader()"]
  96928b1e_d3a9_3b36_08ba_c16229544e5c -->|calls| 7906aa5b_4749_3d37_c2c4_7b6e28fe9050
  a6a94183_4957_7959_5cc5_e6ae948d5910["checkCidLength()"]
  96928b1e_d3a9_3b36_08ba_c16229544e5c -->|calls| a6a94183_4957_7959_5cc5_e6ae948d5910
  style 96928b1e_d3a9_3b36_08ba_c16229544e5c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicHeaderParser.java lines 68–143

    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),
            //  Destination Connection ID Length (8),
            //  Destination Connection ID (0..160),
            //  Source Connection ID Length (8),
            //  Source Connection ID (0..160),
            //  Type-Specific Payload (..),
            //}
            checkReadable(offset, readable, Integer.BYTES);

            // Version uses an unsigned int:
            // https://www.rfc-editor.org/rfc/rfc9000.html#section-15
            version = packet.getUnsignedInt(offset);
            offset += Integer.BYTES;
            type = typeOfLongHeader(first, version);

            int dcidLen = packet.getUnsignedByte(offset);
            checkCidLength(dcidLen);
            offset += Byte.BYTES;
            dcid = sliceCid(packet, offset, dcidLen);
            offset += dcidLen;

            int scidLen = packet.getUnsignedByte(offset);
            checkCidLength(scidLen);
            offset += Byte.BYTES;
            scid = sliceCid(packet, offset, scidLen);
            offset += scidLen;
            token = sliceToken(type, packet, offset, readable);
        }
        callback.process(sender, recipient, packet, type, version, scid, dcid, token);
    }

Domain

Subdomains

Frequently Asked Questions

What does parse() do?
parse() is a function in the netty codebase, defined in codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicHeaderParser.java.
Where is parse() defined?
parse() is defined in codec-classes-quic/src/main/java/io/netty/handler/codec/quic/QuicHeaderParser.java at line 68.
What does parse() call?
parse() calls 3 function(s): checkCidLength, checkReadable, hasShortHeader.

Analyze Your Own Codebase

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

Try Supermodel Free