Home / Function/ testNestedTLV() — netty Function Reference

testNestedTLV() — netty Function Reference

Architecture documentation for the testNestedTLV() function in HAProxyMessageDecoderTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  4b609d4a_d0c1_e524_bca7_ac69c5a43d4f["testNestedTLV()"]
  88909aff_3546_2e28_19d9_812a1929ee17["HAProxyMessageDecoderTest"]
  4b609d4a_d0c1_e524_bca7_ac69c5a43d4f -->|defined in| 88909aff_3546_2e28_19d9_812a1929ee17
  style 4b609d4a_d0c1_e524_bca7_ac69c5a43d4f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-haproxy/src/test/java/io/netty/handler/codec/haproxy/HAProxyMessageDecoderTest.java lines 1199–1258

    @Test
    public void testNestedTLV() throws Exception {
        ByteArrayOutputStream headerWriter = new ByteArrayOutputStream();
        //src_ip = "AAAA", dst_ip = "BBBB", src_port = "CC", dst_port = "DD"
        headerWriter.write(new byte[] {'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'C', 'C', 'D', 'D'});
        //write TLVs
        int countOfTLVs = 8100;
        ByteBuffer tlvLengthBuf = ByteBuffer.allocate(2);
        tlvLengthBuf.order(ByteOrder.BIG_ENDIAN);
        short totalLength = (short) (countOfTLVs * (1 + 2 + 1 + 4));
        for (int i = 0; i < countOfTLVs; i++) {
            //write PP2_TYPE_SSL TLV
            headerWriter.write(0x20); //PP2_TYPE_SSL
            //notice that the TLV length cannot be bigger than 0xffff
            totalLength -= 1 + 2; //exclude type and length themselves
            tlvLengthBuf.clear();
            tlvLengthBuf.putShort(totalLength);
            //add to the header
            headerWriter.write(tlvLengthBuf.array());
            //write client field
            headerWriter.write(1);
            //write verify field
            headerWriter.write(new byte[] {'V', 'V', 'V', 'V'});
            //subtract the client and verify fields
            totalLength -= 1 + 4;
        }
        byte[] header = headerWriter.toByteArray();
        ByteBuffer numsWrite = ByteBuffer.allocate(2);
        numsWrite.order(ByteOrder.BIG_ENDIAN);
        numsWrite.putShort((short) header.length);

        final  ByteBuf data = Unpooled.buffer();
        data.writeBytes(new byte[] {
                (byte) 0x0D,
                (byte) 0x0A,
                (byte) 0x0D,
                (byte) 0x0A,
                (byte) 0x00,
                (byte) 0x0D,
                (byte) 0x0A,
                (byte) 0x51,
                (byte) 0x55,
                (byte) 0x49,
                (byte) 0x54,
                (byte) 0x0A
        });
        //verCmd = 32
        byte versionCmd = 0x20 | 1; //V2 | ProxyCmd
        data.writeByte(versionCmd);
        data.writeByte(17); //TPAF_TCP4_BYTE
        data.writeBytes(numsWrite.array());
        data.writeBytes(header);

        assertThrows(HAProxyProtocolException.class, new Executable() {
            @Override
            public void execute() {
                ch.writeInbound(data);
            }
        });
    }

Domain

Subdomains

Frequently Asked Questions

What does testNestedTLV() do?
testNestedTLV() is a function in the netty codebase, defined in codec-haproxy/src/test/java/io/netty/handler/codec/haproxy/HAProxyMessageDecoderTest.java.
Where is testNestedTLV() defined?
testNestedTLV() is defined in codec-haproxy/src/test/java/io/netty/handler/codec/haproxy/HAProxyMessageDecoderTest.java at line 1199.

Analyze Your Own Codebase

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

Try Supermodel Free