From 0a596388f6714356b5d6d8cdcd88790af29ab4e3 Mon Sep 17 00:00:00 2001 From: Adam Zderski Date: Fri, 15 May 2015 09:36:06 -0400 Subject: [PATCH] Fix for negative flakes The top most bit of the first Vendor byte is causing negative MAC addressed and hence negative flakes. I suggest removing the least significant bit of first vendor byte, the Multi/uni cast indicator which would be the same for all PC NICs then shift the remaining 7 bits down (right) 1. --- .../com/github/rholder/fauxflake/util/MacUtils.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fauxflake-core/src/main/java/com/github/rholder/fauxflake/util/MacUtils.java b/fauxflake-core/src/main/java/com/github/rholder/fauxflake/util/MacUtils.java index 0d2f3e8..aad8e51 100644 --- a/fauxflake-core/src/main/java/com/github/rholder/fauxflake/util/MacUtils.java +++ b/fauxflake-core/src/main/java/com/github/rholder/fauxflake/util/MacUtils.java @@ -92,8 +92,15 @@ public static byte[] realMacAddress() { * Optionally setting the system property OVERRIDE_MAC_PROP to a valid MAC * address will result in it being returned instead. */ - public static byte[] macAddress() { +public static byte[] macAddress() { byte[] override = getOverride(); - return override != null ? override : realMacAddress(); + + if (override == null) + override = realMacAddress(); + + // lop off unicast/multicast lower bit to preserve top vendor bit & resolution. This + override[0] = (byte)((short)(override[0] & 0xff) >> 1); + + return override; } } \ No newline at end of file