summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslator.java6
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslatorTest.java4
-rw-r--r--vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/ByteDataTranslator.java8
3 files changed, 14 insertions, 4 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslator.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslator.java
index 01adefee1..9f788afc6 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslator.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslator.java
@@ -99,7 +99,11 @@ public interface InterfaceDataTranslator extends ByteDataTranslator, JvppReplyCo
final int endIndex = PHYSICAL_ADDRESS_LENGTH;
checkArgument(endIndex <= vppPhysAddress.length,
"Invalid physical address size (%s), expected >= %s", vppPhysAddress.length, endIndex);
- return printHexBinary(vppPhysAddress);
+ // Extended (64-bit) MAC addresses are currently not supported , so use first 48-bits.
+ // Adding support for extended MAC addresses might require yang model change.
+ // Also VPP is not consistent (e.g. for TAP it allows to configure MAC of 6 bytes, but sw_interface_details
+ // contains 8 bytes.
+ return printHexBinary(vppPhysAddress, 0, PHYSICAL_ADDRESS_LENGTH);
}
/**
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslatorTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslatorTest.java
index c58409754..9a9697413 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslatorTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslatorTest.java
@@ -30,7 +30,9 @@ public class InterfaceDataTranslatorTest implements InterfaceDataTranslator {
@Test
public void testVppPhysAddrToYang() throws Exception {
assertEquals("01:02:03:04:05:06", vppPhysAddrToYang(new byte[]{1, 2, 3, 4, 5, 6}));
- assertEquals("0a:0b:0c:0d:0e:0f", vppPhysAddrToYang(new byte[]{0xa, 0xb, 0xc, 0xd, 0xe, 0xf}));
+ // Extended (64-bit) MAC addresses are currently not supported (it might require yang model update),
+ // so test if extended part is ignored
+ assertEquals("0a:0b:0c:0d:0e:0f", vppPhysAddrToYang(new byte[]{0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 0}));
}
@Test(expected = NullPointerException.class)
diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/ByteDataTranslator.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/ByteDataTranslator.java
index 25b8d50f0..c7583fb52 100644
--- a/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/ByteDataTranslator.java
+++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/ByteDataTranslator.java
@@ -100,10 +100,14 @@ public interface ByteDataTranslator {
default String printHexBinary(@Nonnull final byte[] bytes) {
Objects.requireNonNull(bytes, "bytes array should not be null");
+ return printHexBinary(bytes, 0, bytes.length);
+ }
+
+ default String printHexBinary(@Nonnull final byte[] bytes, final int startIndex, final int endIndex) {
StringBuilder str = new StringBuilder();
- Impl.appendHexByte(str, bytes[0]);
- for (int i = 1; i < bytes.length; i++) {
+ Impl.appendHexByte(str, bytes[startIndex]);
+ for (int i = startIndex + 1; i < endIndex; i++) {
str.append(":");
Impl.appendHexByte(str, bytes[i]);
}