summaryrefslogtreecommitdiffstats
path: root/v3po
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2017-10-31 08:50:10 +0100
committerMarek Gradzki <mgradzki@cisco.com>2017-10-31 16:58:35 +0000
commitafc8a4633b0a43173dc0bdba5f678148ae7e58a7 (patch)
treede1b55303f72770eecabc32ab0146a3d7a0a988d /v3po
parent5577ff50e82bbd771bcdb088e1f08e2bfd940b2a (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')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslator.java11
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2/L2FibEntryCustomizer.java11
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2state/L2FibEntryCustomizer.java6
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslatorTest.java2
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2/L2FibEntryCustomizerTest.java23
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2state/L2FibEntryCustomizerTest.java6
6 files changed, 22 insertions, 37 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());
}
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 40bb6b91b..c58409754 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,7 @@ 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, 0, 0}));
+ assertEquals("0a:0b:0c:0d:0e:0f", vppPhysAddrToYang(new byte[]{0xa, 0xb, 0xc, 0xd, 0xe, 0xf}));
}
@Test(expected = NullPointerException.class)
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2/L2FibEntryCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2/L2FibEntryCustomizerTest.java
index 2b096507d..54faa9a1d 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2/L2FibEntryCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2/L2FibEntryCustomizerTest.java
@@ -16,6 +16,7 @@
package io.fd.hc2vpp.v3po.l2;
+import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -81,7 +82,7 @@ public class L2FibEntryCustomizerTest extends WriterCustomizerTest {
doReturn(failedFuture()).when(api).l2FibAddDel(any(L2FibAddDel.class));
}
- private L2FibAddDel generateL2FibAddDelFilterRequest(final long mac, final byte isAdd, final int ifaceIndex) {
+ private L2FibAddDel generateL2FibAddDelFilterRequest(final byte[] mac, final byte isAdd, final int ifaceIndex) {
final L2FibAddDel request = new L2FibAddDel();
request.mac = mac;
request.bdId = BD_ID;
@@ -94,7 +95,7 @@ public class L2FibEntryCustomizerTest extends WriterCustomizerTest {
return request;
}
- private L2FibAddDel generateL2FibAddDelForwardRequest(final long mac, final byte isAdd, final int ifaceIndex) {
+ private L2FibAddDel generateL2FibAddDelForwardRequest(final byte[] mac, final byte isAdd, final int ifaceIndex) {
final L2FibAddDel request = new L2FibAddDel();
request.mac = mac;
request.bdId = BD_ID;
@@ -134,7 +135,7 @@ public class L2FibEntryCustomizerTest extends WriterCustomizerTest {
ArgumentCaptor<L2FibAddDel> argumentCaptor = ArgumentCaptor.forClass(L2FibAddDel.class);
verify(api).l2FibAddDel(argumentCaptor.capture());
final L2FibAddDel actual = argumentCaptor.getValue();
- assertEquals(expected.mac, actual.mac);
+ assertArrayEquals(expected.mac, actual.mac);
assertEquals(expected.bdId, actual.bdId);
assertEquals(expected.swIfIndex, actual.swIfIndex);
assertEquals(expected.isAdd, actual.isAdd);
@@ -144,7 +145,7 @@ public class L2FibEntryCustomizerTest extends WriterCustomizerTest {
@Test
public void testCreateFilter() throws Exception {
- final long address_vpp = 0x0102030405060000L;
+ final byte[] address_vpp = new byte[]{1, 2, 3, 4, 5, 6};
final PhysAddress address = new PhysAddress("01:02:03:04:05:06");
final L2FibEntry entry = generateL2FibFilterEntry(address);
final InstanceIdentifier<L2FibEntry> id = getL2FibEntryId(address);
@@ -158,7 +159,7 @@ public class L2FibEntryCustomizerTest extends WriterCustomizerTest {
@Test
public void testCreateForward() throws Exception {
- final long address_vpp = 0x0102030405060000L;
+ final byte[] address_vpp = new byte[]{1, 2, 3, 4, 5, 6};
final PhysAddress address = new PhysAddress("01:02:03:04:05:06");
final L2FibEntry entry = generateL2FibForwardEntry(address);
final InstanceIdentifier<L2FibEntry> id = getL2FibEntryId(address);
@@ -172,7 +173,7 @@ public class L2FibEntryCustomizerTest extends WriterCustomizerTest {
@Test
public void testCreateFilterFailed() throws Exception {
- final long address_vpp = 0x1122334455660000L;
+ final byte[] address_vpp = new byte[]{0x11, 0x22 ,0x33, 0x44 ,0x55, 0x66};
final PhysAddress address = new PhysAddress("11:22:33:44:55:66");
final L2FibEntry entry = generateL2FibFilterEntry(address);
final InstanceIdentifier<L2FibEntry> id = getL2FibEntryId(address);
@@ -191,7 +192,7 @@ public class L2FibEntryCustomizerTest extends WriterCustomizerTest {
@Test
public void testCreateForwardFailed() throws Exception {
- final long address_vpp = 0x1122334455660000L;
+ final byte[] address_vpp = new byte[]{0x11, 0x22 ,0x33, 0x44 ,0x55, 0x66};
final PhysAddress address = new PhysAddress("11:22:33:44:55:66");
final L2FibEntry entry = generateL2FibForwardEntry(address);
final InstanceIdentifier<L2FibEntry> id = getL2FibEntryId(address);
@@ -216,7 +217,7 @@ public class L2FibEntryCustomizerTest extends WriterCustomizerTest {
@Test
public void testDeleteFilter() throws Exception {
- final long address_vpp = 0x1122334455660000L;
+ final byte[] address_vpp = new byte[]{0x11, 0x22 ,0x33, 0x44 ,0x55, 0x66};
final PhysAddress address = new PhysAddress("11:22:33:44:55:66");
final L2FibEntry entry = generateL2FibFilterEntry(address);
final InstanceIdentifier<L2FibEntry> id = getL2FibEntryId(address);
@@ -230,7 +231,7 @@ public class L2FibEntryCustomizerTest extends WriterCustomizerTest {
@Test
public void testDeleteForward() throws Exception {
- final long address_vpp = 0x1122334455660000L;
+ final byte[] address_vpp = new byte[]{0x11, 0x22 ,0x33, 0x44 ,0x55, 0x66};
final PhysAddress address = new PhysAddress("11:22:33:44:55:66");
final L2FibEntry entry = generateL2FibForwardEntry(address);
final InstanceIdentifier<L2FibEntry> id = getL2FibEntryId(address);
@@ -245,7 +246,7 @@ public class L2FibEntryCustomizerTest extends WriterCustomizerTest {
@Test
public void testDeleteFilterFailed() throws Exception {
- final long address_vpp = 0x0102030405060000L;
+ final byte[] address_vpp = new byte[]{1, 2, 3, 4, 5, 6};
final PhysAddress address = new PhysAddress("01:02:03:04:05:06");
final L2FibEntry entry = generateL2FibFilterEntry(address);
final InstanceIdentifier<L2FibEntry> id = getL2FibEntryId(address);
@@ -264,7 +265,7 @@ public class L2FibEntryCustomizerTest extends WriterCustomizerTest {
@Test
public void testDeleteForwardFailed() throws Exception {
- final long address_vpp = 0x0102030405060000L;
+ final byte[] address_vpp = new byte[]{1, 2, 3, 4, 5, 6};
final PhysAddress address = new PhysAddress("01:02:03:04:05:06");
final L2FibEntry entry = generateL2FibForwardEntry(address);
final InstanceIdentifier<L2FibEntry> id = getL2FibEntryId(address);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2state/L2FibEntryCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2state/L2FibEntryCustomizerTest.java
index a8e200edd..40dbe797b 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2state/L2FibEntryCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2state/L2FibEntryCustomizerTest.java
@@ -86,7 +86,7 @@ public class L2FibEntryCustomizerTest extends ListReaderCustomizerTest<L2FibEntr
@Test
public void testRead() throws Exception {
- final long address_vpp = 0x0000010203040506L;
+ final byte[] address_vpp = new byte[]{1, 2, 3, 4, 5, 6};
final PhysAddress address = new PhysAddress("01:02:03:04:05:06");
defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
@@ -103,7 +103,7 @@ public class L2FibEntryCustomizerTest extends ListReaderCustomizerTest<L2FibEntr
verify(builder).setKey(new L2FibEntryKey(address));
}
- private L2FibTableDetails generateL2FibEntry(final long mac) {
+ private L2FibTableDetails generateL2FibEntry(final byte[] mac) {
final L2FibTableDetails entry = new L2FibTableDetails();
entry.mac = mac;
entry.swIfIndex = IFACE_ID;
@@ -112,7 +112,7 @@ public class L2FibEntryCustomizerTest extends ListReaderCustomizerTest<L2FibEntr
@Test
public void testGetAllIds() throws Exception {
- final long address_vpp = 0x0000112233445566L;
+ final byte[] address_vpp = new byte[]{0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
final PhysAddress address = new PhysAddress("11:22:33:44:55:66");
whenL2FibTableDumpThenReturn(Collections.singletonList(generateL2FibEntry(address_vpp)));