encodeOptEcsRecord() — netty Function Reference
Architecture documentation for the encodeOptEcsRecord() function in DefaultDnsRecordEncoder.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD e1aa726e_3571_f1cd_26ca_fe4a65acaf15["encodeOptEcsRecord()"] 7acd50be_5ea0_6375_ac42_d023d53b4027["DefaultDnsRecordEncoder"] e1aa726e_3571_f1cd_26ca_fe4a65acaf15 -->|defined in| 7acd50be_5ea0_6375_ac42_d023d53b4027 e69a3483_88a7_31ba_0c72_3a97b751f42a["encodeRecord()"] e69a3483_88a7_31ba_0c72_3a97b751f42a -->|calls| e1aa726e_3571_f1cd_26ca_fe4a65acaf15 4433c7f7_f393_24fc_324a_800a9d0c2833["encodeRecord0()"] e1aa726e_3571_f1cd_26ca_fe4a65acaf15 -->|calls| 4433c7f7_f393_24fc_324a_800a9d0c2833 73402557_bece_7091_6c4d_50be4b96831a["calculateEcsAddressLength()"] e1aa726e_3571_f1cd_26ca_fe4a65acaf15 -->|calls| 73402557_bece_7091_6c4d_50be4b96831a 5999e8f6_ef45_7750_d4c1_7a23377b4abf["padWithZeros()"] e1aa726e_3571_f1cd_26ca_fe4a65acaf15 -->|calls| 5999e8f6_ef45_7750_d4c1_7a23377b4abf style e1aa726e_3571_f1cd_26ca_fe4a65acaf15 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-dns/src/main/java/io/netty/handler/codec/dns/DefaultDnsRecordEncoder.java lines 85–128
private void encodeOptEcsRecord(DnsOptEcsRecord record, ByteBuf out) throws Exception {
encodeRecord0(record, out);
int sourcePrefixLength = record.sourcePrefixLength();
int scopePrefixLength = record.scopePrefixLength();
int lowOrderBitsToPreserve = sourcePrefixLength & PREFIX_MASK;
byte[] bytes = record.address();
int addressBits = bytes.length << 3;
if (addressBits < sourcePrefixLength || sourcePrefixLength < 0) {
throw new IllegalArgumentException(sourcePrefixLength + ": " +
sourcePrefixLength + " (expected: 0 >= " + addressBits + ')');
}
// See https://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml
final short addressNumber = (short) (bytes.length == 4 ? 1 : 2);
int payloadLength = calculateEcsAddressLength(sourcePrefixLength, lowOrderBitsToPreserve);
int fullPayloadLength = 2 + // OPTION-CODE
2 + // OPTION-LENGTH
2 + // FAMILY
1 + // SOURCE PREFIX-LENGTH
1 + // SCOPE PREFIX-LENGTH
payloadLength; // ADDRESS...
out.writeShort(fullPayloadLength);
out.writeShort(8); // This is the defined type for ECS.
out.writeShort(fullPayloadLength - 4); // Not include OPTION-CODE and OPTION-LENGTH
out.writeShort(addressNumber);
out.writeByte(sourcePrefixLength);
out.writeByte(scopePrefixLength); // Must be 0 in queries.
if (lowOrderBitsToPreserve > 0) {
int bytesLength = payloadLength - 1;
out.writeBytes(bytes, 0, bytesLength);
// Pad the leftover of the last byte with zeros.
out.writeByte(padWithZeros(bytes[bytesLength], lowOrderBitsToPreserve));
} else {
// The sourcePrefixLength align with Byte so just copy in the bytes directly.
out.writeBytes(bytes, 0, payloadLength);
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does encodeOptEcsRecord() do?
encodeOptEcsRecord() is a function in the netty codebase, defined in codec-dns/src/main/java/io/netty/handler/codec/dns/DefaultDnsRecordEncoder.java.
Where is encodeOptEcsRecord() defined?
encodeOptEcsRecord() is defined in codec-dns/src/main/java/io/netty/handler/codec/dns/DefaultDnsRecordEncoder.java at line 85.
What does encodeOptEcsRecord() call?
encodeOptEcsRecord() calls 3 function(s): calculateEcsAddressLength, encodeRecord0, padWithZeros.
What calls encodeOptEcsRecord()?
encodeOptEcsRecord() is called by 1 function(s): encodeRecord.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free