diff options
author | 2016-10-04 16:44:47 +0200 | |
---|---|---|
committer | 2016-10-05 11:52:37 +0000 | |
commit | 6e92b4740d62b5977590f8a247b08eb945b9e5b7 (patch) | |
tree | 366c1f8536528637d58ba55088b3a3c90b522283 /vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/vpp/util/MacTranslator.java | |
parent | 4cd8aad5217a5225a2a33b448478dd81548e38b1 (diff) |
HONEYCOMB-138 - Lisp L2 Support
Change-Id: Idff4776a64a88be2e0a45ab1927978e40876ea92
Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/vpp/util/MacTranslator.java')
-rw-r--r-- | vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/vpp/util/MacTranslator.java | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/vpp/util/MacTranslator.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/vpp/util/MacTranslator.java index af26b11b2..a947f95c6 100644 --- a/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/vpp/util/MacTranslator.java +++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/honeycomb/translate/vpp/util/MacTranslator.java @@ -20,6 +20,7 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.base.Splitter; +import java.util.Arrays; import java.util.List; import java.util.function.BiConsumer; import javax.annotation.Nonnull; @@ -64,17 +65,17 @@ public interface MacTranslator { * Converts byte array to address string ,not separated with ":" */ default String byteArrayToMacUnseparated(byte[] address) { - checkArgument(address.length == 6, "Illegal array length"); - return Hex.encodeHexString(address); + checkArgument(address.length >= 6, "Illegal array length"); + return Hex.encodeHexString(Arrays.copyOf(address, 6)); } /** * Converts byte array to address string ,separated with ":" */ default String byteArrayToMacSeparated(byte[] address) { - checkArgument(address.length == 6, "Illegal array length"); + checkArgument(address.length >= 6, "Illegal array length"); - String unseparatedAddress = Hex.encodeHexString(address); + String unseparatedAddress = Hex.encodeHexString(Arrays.copyOf(address, 6)); String separated = ""; for (int i = 0; i < unseparatedAddress.length(); i = i + 2) { |