Home / Class/ DefaultDnsOptEcsRecord Class — netty Architecture

DefaultDnsOptEcsRecord Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  ffb50d26_5561_376f_5fc0_a8061b7bbfc6["DefaultDnsOptEcsRecord"]
  50d1bbea_5a9c_7a72_37b7_fe6871b6de97["DefaultDnsOptEcsRecord.java"]
  ffb50d26_5561_376f_5fc0_a8061b7bbfc6 -->|defined in| 50d1bbea_5a9c_7a72_37b7_fe6871b6de97
  4d8e5a49_46fc_13df_5a22_c2c124865430["DefaultDnsOptEcsRecord()"]
  ffb50d26_5561_376f_5fc0_a8061b7bbfc6 -->|method| 4d8e5a49_46fc_13df_5a22_c2c124865430
  6c726221_86a3_c6a8_91fd_36e2f57c5112["localAddress()"]
  ffb50d26_5561_376f_5fc0_a8061b7bbfc6 -->|method| 6c726221_86a3_c6a8_91fd_36e2f57c5112
  ee55d6ef_ed8b_e52a_68a7_63b8f64584f6["verifyAddress()"]
  ffb50d26_5561_376f_5fc0_a8061b7bbfc6 -->|method| ee55d6ef_ed8b_e52a_68a7_63b8f64584f6
  d93eaeb8_747b_7cf1_a541_2259242963f1["sourcePrefixLength()"]
  ffb50d26_5561_376f_5fc0_a8061b7bbfc6 -->|method| d93eaeb8_747b_7cf1_a541_2259242963f1
  abe307d2_5145_ea38_e1ae_1c5bb4465350["scopePrefixLength()"]
  ffb50d26_5561_376f_5fc0_a8061b7bbfc6 -->|method| abe307d2_5145_ea38_e1ae_1c5bb4465350
  1125a687_3284_c266_2f58_08fdb16376b0["address()"]
  ffb50d26_5561_376f_5fc0_a8061b7bbfc6 -->|method| 1125a687_3284_c266_2f58_08fdb16376b0
  a3da17ef_e79f_11b8_00b9_79bafa86b67c["String()"]
  ffb50d26_5561_376f_5fc0_a8061b7bbfc6 -->|method| a3da17ef_e79f_11b8_00b9_79bafa86b67c

Relationship Graph

Source Code

codec-dns/src/main/java/io/netty/handler/codec/dns/DefaultDnsOptEcsRecord.java lines 28–128

public final class DefaultDnsOptEcsRecord extends AbstractDnsOptPseudoRrRecord implements DnsOptEcsRecord {
    private final int srcPrefixLength;
    private final byte[] address;

    /**
     * Creates a new instance.
     *
     * @param maxPayloadSize the suggested max payload size in bytes
     * @param extendedRcode the extended rcode
     * @param version the version
     * @param srcPrefixLength the prefix length
     * @param address the bytes of the {@link InetAddress} to use
     */
    public DefaultDnsOptEcsRecord(int maxPayloadSize, int extendedRcode, int version,
                                  int srcPrefixLength, byte[] address) {
        super(maxPayloadSize, extendedRcode, version);
        this.srcPrefixLength = srcPrefixLength;
        this.address = verifyAddress(address).clone();
    }

    /**
     * Creates a new instance.
     *
     * @param maxPayloadSize the suggested max payload size in bytes
     * @param srcPrefixLength the prefix length
     * @param address the bytes of the {@link InetAddress} to use
     */
    public DefaultDnsOptEcsRecord(int maxPayloadSize, int srcPrefixLength, byte[] address) {
        this(maxPayloadSize, 0, 0, srcPrefixLength, address);
    }

    /**
     * Creates a new instance.
     *
     * @param maxPayloadSize    the suggested max payload size in bytes
     * @param protocolFamily    the {@link InternetProtocolFamily} to use. This should be the same as the one used to
     *                          send the query.
     * @deprecated              use {@link DefaultDnsOptEcsRecord#DefaultDnsOptEcsRecord(int, SocketProtocolFamily)}
     */
    @Deprecated
    public DefaultDnsOptEcsRecord(int maxPayloadSize, InternetProtocolFamily protocolFamily) {
        this(maxPayloadSize, 0, 0, 0, protocolFamily.localhost().getAddress());
    }

    /**
     * Creates a new instance.
     *
     * @param maxPayloadSize        the suggested max payload size in bytes
     * @param socketProtocolFamily  the {@link SocketProtocolFamily} to use. This should be the same as the one used to
     *                              send the query.
     */
    public DefaultDnsOptEcsRecord(int maxPayloadSize, SocketProtocolFamily socketProtocolFamily) {
        this(maxPayloadSize, 0, 0, 0, localAddress(socketProtocolFamily));
    }

    private static byte[] localAddress(SocketProtocolFamily family) {
        switch (family) {
            case INET:
                return NetUtil.LOCALHOST4.getAddress();
            case INET6:
                return NetUtil.LOCALHOST6.getAddress();
            default:
                return null;
        }
    }

    private static byte[] verifyAddress(byte[] bytes) {
        if (bytes != null && bytes.length == 4 || bytes.length == 16) {
            return bytes;
        }
        throw new IllegalArgumentException("bytes.length must either 4 or 16");
    }

    @Override
    public int sourcePrefixLength() {
        return srcPrefixLength;
    }

    @Override
    public int scopePrefixLength() {
        return 0;

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free