diff options
author | Marek Gradzki <mgradzki@cisco.com> | 2017-10-31 08:50:10 +0100 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2017-10-31 16:58:35 +0000 |
commit | afc8a4633b0a43173dc0bdba5f678148ae7e58a7 (patch) | |
tree | de1b55303f72770eecabc32ab0146a3d7a0a988d /v3po/v3po2vpp/src/main/java/io/fd | |
parent | 5577ff50e82bbd771bcdb088e1f08e2bfd940b2a (diff) |
Adapt to mac address representation change in l2.api
https://gerrit.fd.io/r/#/c/9090/ changes mac representation
from u64 to u8[]
Change-Id: Ia82d5652926f8bd10c1c8fc3ad0e147b35dbee4c
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/main/java/io/fd')
3 files changed, 6 insertions, 22 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 ec47ee2f2..01adefee1 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 @@ -95,16 +95,11 @@ public interface InterfaceDataTranslator extends ByteDataTranslator, JvppReplyCo * @throws IllegalArgumentException if vppPhysAddress.length < 6 */ default String vppPhysAddrToYang(@Nonnull final byte[] vppPhysAddress) { - return vppPhysAddrToYang(vppPhysAddress, 0); - } - - default String vppPhysAddrToYang(@Nonnull final byte[] vppPhysAddress, final int startIndex) { Objects.requireNonNull(vppPhysAddress, "Empty physical address bytes"); - final int endIndex = startIndex + PHYSICAL_ADDRESS_LENGTH; + final int endIndex = PHYSICAL_ADDRESS_LENGTH; checkArgument(endIndex <= vppPhysAddress.length, - "Invalid physical address size (%s) for given startIndex (%s), expected >= %s", vppPhysAddress.length, - startIndex, endIndex); - return printHexBinary(vppPhysAddress, startIndex, endIndex); + "Invalid physical address size (%s), expected >= %s", vppPhysAddress.length, endIndex); + return printHexBinary(vppPhysAddress); } /** diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2/L2FibEntryCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2/L2FibEntryCustomizer.java index 1b5248f79..8f29aed5e 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2/L2FibEntryCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2/L2FibEntryCustomizer.java @@ -19,7 +19,6 @@ package io.fd.hc2vpp.v3po.l2; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; -import com.google.common.primitives.Longs; import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; @@ -114,7 +113,7 @@ public class L2FibEntryCustomizer extends FutureJVppCustomizer private L2FibAddDel createL2FibRequest(final L2FibEntry entry, final int bdId, final int swIfIndex, boolean isAdd) { final L2FibAddDel request = new L2FibAddDel(); - request.mac = macToLong(entry.getPhysAddress().getValue()); + request.mac = parseMac(entry.getPhysAddress().getValue()); request.bdId = bdId; request.swIfIndex = swIfIndex; request.isAdd = booleanToByte(isAdd); @@ -124,12 +123,4 @@ public class L2FibEntryCustomizer extends FutureJVppCustomizer } return request; } - - // mac address is string of the form: 11:22:33:44:55:66 - // but VPP expects long value in the format 11:22:33:44:55:66:XX:XX - private long macToLong(final String macAddress) { - final byte[] mac = parseMac(macAddress); - return Longs.fromBytes(mac[0], mac[1], mac[2], mac[3], - mac[4], mac[5], (byte) 0, (byte) 0); - } } diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2state/L2FibEntryCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2state/L2FibEntryCustomizer.java index 61780f52f..e552ce870 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2state/L2FibEntryCustomizer.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2state/L2FibEntryCustomizer.java @@ -17,7 +17,6 @@ package io.fd.hc2vpp.v3po.l2state; import com.google.common.base.Preconditions; -import com.google.common.primitives.Longs; import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer; import io.fd.hc2vpp.common.translate.util.NamingContext; @@ -85,7 +84,7 @@ public final class L2FibEntryCustomizer extends FutureJVppCustomizer try { // TODO HONEYCOMB-186 use cached l2FibTable final L2FibTableDetails entry = dumpL2Fibs(id, bdId).stream().filter(e -> key.getPhysAddress() - .equals(new PhysAddress(vppPhysAddrToYang(Longs.toByteArray(e.mac), 2)))) + .equals(new PhysAddress(vppPhysAddrToYang((e.mac))))) .collect(SINGLE_ITEM_COLLECTOR); builder.setAction(byteToBoolean(entry.filterMac) @@ -131,8 +130,7 @@ public final class L2FibEntryCustomizer extends FutureJVppCustomizer LOG.debug("Reading L2 FIB for bridge domain {} (bdId={})", bridgeDomainKey, bdId); return dumpL2Fibs(id, bdId).stream() - .map(entry -> new L2FibEntryKey( - new PhysAddress(vppPhysAddrToYang(Longs.toByteArray(entry.mac), 2)))) + .map(entry -> new L2FibEntryKey(new PhysAddress(vppPhysAddrToYang(entry.mac)))) .collect(Collectors.toList()); } |