Home / Class/ TcpDnsResponseDecoder Class — netty Architecture

TcpDnsResponseDecoder Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  0ea4f3a6_4447_8889_1e98_8cc6ab5856a7["TcpDnsResponseDecoder"]
  ebdfb27d_9f04_4867_290a_3296c4f98ba0["TcpDnsResponseDecoder.java"]
  0ea4f3a6_4447_8889_1e98_8cc6ab5856a7 -->|defined in| ebdfb27d_9f04_4867_290a_3296c4f98ba0
  3ec263f3_493c_889b_e4c8_82c0400a1a6c["TcpDnsResponseDecoder()"]
  0ea4f3a6_4447_8889_1e98_8cc6ab5856a7 -->|method| 3ec263f3_493c_889b_e4c8_82c0400a1a6c
  c162ab96_fe13_124f_3df6_883c0a614bd9["Object()"]
  0ea4f3a6_4447_8889_1e98_8cc6ab5856a7 -->|method| c162ab96_fe13_124f_3df6_883c0a614bd9
  980ac98a_8dac_44a7_f654_2ecf4764ddf3["ByteBuf()"]
  0ea4f3a6_4447_8889_1e98_8cc6ab5856a7 -->|method| 980ac98a_8dac_44a7_f654_2ecf4764ddf3

Relationship Graph

Source Code

codec-dns/src/main/java/io/netty/handler/codec/dns/TcpDnsResponseDecoder.java lines 24–70

public final class TcpDnsResponseDecoder extends LengthFieldBasedFrameDecoder {

    private final DnsResponseDecoder<SocketAddress> responseDecoder;

    /**
     * Creates a new decoder with {@linkplain DnsRecordDecoder#DEFAULT the default record decoder}.
     */
    public TcpDnsResponseDecoder() {
        this(DnsRecordDecoder.DEFAULT, 64 * 1024);
    }

    /**
     * Creates a new decoder with the specified {@code recordDecoder} and {@code maxFrameLength}
     */
    public TcpDnsResponseDecoder(DnsRecordDecoder recordDecoder, int maxFrameLength) {
        // Length is two octets as defined by RFC-7766
        // See https://tools.ietf.org/html/rfc7766#section-8
        super(maxFrameLength, 0, 2, 0, 2);

        this.responseDecoder = new DnsResponseDecoder<SocketAddress>(recordDecoder) {
            @Override
            protected DnsResponse newResponse(SocketAddress sender, SocketAddress recipient,
                                              int id, DnsOpCode opCode, DnsResponseCode responseCode) {
                return new DefaultDnsResponse(id, opCode, responseCode);
            }
        };
    }

    @Override
    protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
        ByteBuf frame = (ByteBuf) super.decode(ctx, in);
        if (frame == null) {
            return null;
        }

        try {
            return responseDecoder.decode(ctx.channel().remoteAddress(), ctx.channel().localAddress(), frame.slice());
        } finally {
            frame.release();
        }
    }

    @Override
    protected ByteBuf extractFrame(ChannelHandlerContext ctx, ByteBuf buffer, int index, int length) {
        return buffer.copy(index, length);
    }
}

Frequently Asked Questions

What is the TcpDnsResponseDecoder class?
TcpDnsResponseDecoder is a class in the netty codebase, defined in codec-dns/src/main/java/io/netty/handler/codec/dns/TcpDnsResponseDecoder.java.
Where is TcpDnsResponseDecoder defined?
TcpDnsResponseDecoder is defined in codec-dns/src/main/java/io/netty/handler/codec/dns/TcpDnsResponseDecoder.java at line 24.

Analyze Your Own Codebase

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

Try Supermodel Free