diff options
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java')
-rw-r--r-- | v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java index b9a25974b..1db7b8a42 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java @@ -102,7 +102,6 @@ public final class InterfaceUtils { } // TODO rename and move to V3poUtils - /** * Reads first 6 bytes of supplied byte array and converts to string as Yang dictates <p> Replace later with * https://git.opendaylight.org/gerrit/#/c/34869/10/model/ietf/ietf-type- util/src/main/ @@ -114,13 +113,18 @@ public final class InterfaceUtils { * @throws IllegalArgumentException if vppPhysAddress.length < 6 */ public static String vppPhysAddrToYang(@Nonnull final byte[] vppPhysAddress) { + return vppPhysAddrToYang(vppPhysAddress, 0); + } + + public static String vppPhysAddrToYang(@Nonnull final byte[] vppPhysAddress, int startIndex) { Objects.requireNonNull(vppPhysAddress, "Empty physical address bytes"); - Preconditions.checkArgument(PHYSICAL_ADDRESS_LENGTH <= vppPhysAddress.length, - "Invalid physical address size %s, expected >= 6", vppPhysAddress.length); + final int endIndex = startIndex+PHYSICAL_ADDRESS_LENGTH; + Preconditions.checkArgument(endIndex <= vppPhysAddress.length, + "Invalid physical address size (%s) for given startIndex (%d), expected >= %d", vppPhysAddress.length, startIndex, endIndex); StringBuilder physAddr = new StringBuilder(); - appendHexByte(physAddr, vppPhysAddress[0]); - for (int i = 1; i < PHYSICAL_ADDRESS_LENGTH; i++) { + appendHexByte(physAddr, vppPhysAddress[startIndex]); + for (int i = startIndex+1; i < endIndex; i++) { physAddr.append(":"); appendHexByte(physAddr, vppPhysAddress[i]); } |