diff options
author | Marek Gradzki <mgradzki@cisco.com> | 2016-06-10 15:28:09 +0200 |
---|---|---|
committer | Maros Marsalek <mmarsale@cisco.com> | 2016-06-15 10:32:09 +0000 |
commit | 5502b2eb50c9a3f9fb23ab758036bdbd67fbd32d (patch) | |
tree | 66095b607083e9d356400c02bde893fa1893565a /v3po/v3po2vpp/src/main/java/io/fd/honeycomb/v3po/translate/v3po/interfacesstate/InterfaceUtils.java | |
parent | 53ec754bd9ca566bd718dd915ae8d83a67b0f7f8 (diff) |
HONEYCOMB-91: Create read customizer for L2FibEntry
Change-Id: I0ad5d98ba6c9442c79b21bf04be07b81d04a4595
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
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]); } |