compareAddresses() — netty Function Reference
Architecture documentation for the compareAddresses() function in MacAddressUtil.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD bce5fa35_f827_f8d9_1f74_97f9adbfbbef["compareAddresses()"] a4685b43_b51c_914d_456a_1efa65aff7a6["MacAddressUtil"] bce5fa35_f827_f8d9_1f74_97f9adbfbbef -->|defined in| a4685b43_b51c_914d_456a_1efa65aff7a6 076ea31f_ecd7_dd77_e9b3_a6aaa2aded58["bestAvailableMac()"] 076ea31f_ecd7_dd77_e9b3_a6aaa2aded58 -->|calls| bce5fa35_f827_f8d9_1f74_97f9adbfbbef 9305d4fa_a1fb_1272_769e_bfae8c4ad4c4["scoreAddress()"] bce5fa35_f827_f8d9_1f74_97f9adbfbbef -->|calls| 9305d4fa_a1fb_1272_769e_bfae8c4ad4c4 style bce5fa35_f827_f8d9_1f74_97f9adbfbbef fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
common/src/main/java/io/netty/util/internal/MacAddressUtil.java lines 202–243
static int compareAddresses(byte[] current, byte[] candidate) {
if (candidate == null || candidate.length < EUI48_MAC_ADDRESS_LENGTH) {
return 1;
}
// Must not be filled with only 0 and 1.
boolean onlyZeroAndOne = true;
for (byte b: candidate) {
if (b != 0 && b != 1) {
onlyZeroAndOne = false;
break;
}
}
if (onlyZeroAndOne) {
return 1;
}
// Must not be a multicast address
if ((candidate[0] & 1) != 0) {
return 1;
}
// Prefer globally unique address.
if ((candidate[0] & 2) == 0) {
if (current.length != 0 && (current[0] & 2) == 0) {
// Both current and candidate are globally unique addresses.
return 0;
} else {
// Only candidate is globally unique.
return -1;
}
} else {
if (current.length != 0 && (current[0] & 2) == 0) {
// Only current is globally unique.
return 1;
} else {
// Both current and candidate are non-unique.
return 0;
}
}
}
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does compareAddresses() do?
compareAddresses() is a function in the netty codebase, defined in common/src/main/java/io/netty/util/internal/MacAddressUtil.java.
Where is compareAddresses() defined?
compareAddresses() is defined in common/src/main/java/io/netty/util/internal/MacAddressUtil.java at line 202.
What does compareAddresses() call?
compareAddresses() calls 1 function(s): scoreAddress.
What calls compareAddresses()?
compareAddresses() is called by 1 function(s): bestAvailableMac.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free