Package io.netty.util.internal
Class MacAddressUtil
java.lang.Object
io.netty.util.internal.MacAddressUtil
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final intprivate static final InternalLogger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]Obtains the best MAC address found on local network interfaces.(package private) static intcompareAddresses(byte[] current, byte[] candidate) private static intcompareAddresses(InetAddress current, InetAddress candidate) static byte[]Returns the result ofbestAvailableMac()if non-nullotherwise returns a random EUI-64 MAC address.static StringformatAddress(byte[] addr) static byte[]Parse a EUI-48, MAC-48, or EUI-64 MAC address from aStringand return it as abyte[].private static intscoreAddress(InetAddress addr) private static voidvalidateMacSeparator(char separator)
-
Field Details
-
logger
-
EUI64_MAC_ADDRESS_LENGTH
private static final int EUI64_MAC_ADDRESS_LENGTH- See Also:
-
EUI48_MAC_ADDRESS_LENGTH
private static final int EUI48_MAC_ADDRESS_LENGTH- See Also:
-
-
Constructor Details
-
MacAddressUtil
private MacAddressUtil()
-
-
Method Details
-
bestAvailableMac
public static byte[] bestAvailableMac()Obtains the best MAC address found on local network interfaces. Generally speaking, an active network interface used on public networks is better than a local network interface.- Returns:
- byte array containing a MAC. null if no MAC can be found.
-
defaultMachineId
public static byte[] defaultMachineId()Returns the result ofbestAvailableMac()if non-nullotherwise returns a random EUI-64 MAC address. -
parseMAC
Parse a EUI-48, MAC-48, or EUI-64 MAC address from aStringand return it as abyte[].- Parameters:
value- The string representation of the MAC address.- Returns:
- The byte representation of the MAC address.
-
validateMacSeparator
private static void validateMacSeparator(char separator) -
formatAddress
- Parameters:
addr- byte array of a MAC address.- Returns:
- hex formatted MAC address.
-
compareAddresses
static int compareAddresses(byte[] current, byte[] candidate) - Returns:
- positive - current is better, 0 - cannot tell from MAC addr, negative - candidate is better.
-
compareAddresses
- Returns:
- positive - current is better, 0 - cannot tell, negative - candidate is better
-
scoreAddress
-