summaryrefslogtreecommitdiffstats
path: root/lisp/lisp2vpp
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2016-11-24 11:56:40 +0100
committerJan Srnicek <jsrnicek@cisco.com>2016-11-24 11:56:40 +0100
commite259ab7990b8179eda4462907ecebccd0e85b587 (patch)
treeb0326a66b0a9d775e79dfbc495568df94643f3ef /lisp/lisp2vpp
parent927fb75d969b2d39c91ae6735f0127646348b73c (diff)
HON-3 - Address logic refactoring
Ipv4/6 address logic refactored to not use InetAddresses.fromLittleEndianArray to prevent unnecessary reverting of address arrays after fix introduced by VPP-132. Removed unused ***reverted variants of conversion logic. Tested with these plugins - Lisp - V3po - Nat Change-Id: I6a0728f8b3dffd04e2edd822ec61542216cca824 Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'lisp/lisp2vpp')
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizer.java4
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizer.java2
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/util/EidTranslator.java20
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocalMappingCustomizerTest.java4
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java4
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RemoteMappingCustomizerTest.java7
6 files changed, 20 insertions, 21 deletions
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizer.java
index cf6ca8b83..c2a7f0bd8 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/MapResolverCustomizer.java
@@ -87,7 +87,7 @@ public class MapResolverCustomizer extends FutureJVppCustomizer
final LispMapResolverDetails mapResolverDetails =
dumpOptional.get().lispMapResolverDetails.stream()
.filter(a -> addressesEqual(key.getIpAddress(),
- arrayToIpAddressReversed(byteToBoolean(a.isIpv6), a.ipAddress)))
+ arrayToIpAddress(byteToBoolean(a.isIpv6), a.ipAddress)))
.collect(RWUtils.singleItemCollector());
builder.setKey(key);
@@ -115,7 +115,7 @@ public class MapResolverCustomizer extends FutureJVppCustomizer
return dumpOptional.get().lispMapResolverDetails.stream()
.map(resolver -> new MapResolverKey(
- arrayToIpAddressReversed(byteToBoolean(resolver.isIpv6), resolver.ipAddress)))
+ arrayToIpAddress(byteToBoolean(resolver.isIpv6), resolver.ipAddress)))
.collect(Collectors.toList());
}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizer.java
index 3b00d2800..27b51218c 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizer.java
@@ -292,7 +292,7 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer
}
private Locator detailsToLocator(final LispLocatorDetails details) {
- final IpAddress address = arrayToIpAddressReversed(byteToBoolean(details.isIpv6), details.ipAddress);
+ final IpAddress address = arrayToIpAddress(byteToBoolean(details.isIpv6), details.ipAddress);
return new LocatorBuilder()
.setAddress(address)
.setKey(new LocatorKey(address))
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/util/EidTranslator.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/util/EidTranslator.java
index 347720958..3110faf07 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/util/EidTranslator.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/util/EidTranslator.java
@@ -92,12 +92,12 @@ public interface EidTranslator extends AddressTranslator, EidMetadataProvider {
switch (type) {
case IPV4: {
return newLocalEidBuilder(Ipv4Afi.class, vni).setAddress(
- new Ipv4Builder().setIpv4(arrayToIpv4AddressNoZoneReversed(address)).build())
+ new Ipv4Builder().setIpv4(arrayToIpv4AddressNoZone(address)).build())
.build();
}
case IPV6: {
return newLocalEidBuilder(Ipv6Afi.class, vni).setAddress(
- new Ipv6Builder().setIpv6(arrayToIpv6AddressNoZoneReversed(address)).build())
+ new Ipv6Builder().setIpv6(arrayToIpv6AddressNoZone(address)).build())
.build();
}
case MAC: {
@@ -118,14 +118,14 @@ public interface EidTranslator extends AddressTranslator, EidMetadataProvider {
case IPV4: {
return newRemoteEidBuilder(Ipv4Afi.class, vni)
.setAddress(
- new Ipv4Builder().setIpv4(arrayToIpv4AddressNoZoneReversed(address))
+ new Ipv4Builder().setIpv4(arrayToIpv4AddressNoZone(address))
.build())
.build();
}
case IPV6: {
return newRemoteEidBuilder(Ipv6Afi.class, vni)
.setAddress(
- new Ipv6Builder().setIpv6(arrayToIpv6AddressNoZoneReversed(address))
+ new Ipv6Builder().setIpv6(arrayToIpv6AddressNoZone(address))
.build())
.build();
}
@@ -146,14 +146,14 @@ public interface EidTranslator extends AddressTranslator, EidMetadataProvider {
case IPV4: {
return newEidBuilderLocal(Ipv4Afi.class, vni)
.setAddress(
- new Ipv4Builder().setIpv4(arrayToIpv4AddressNoZoneReversed(address))
+ new Ipv4Builder().setIpv4(arrayToIpv4AddressNoZone(address))
.build())
.build();
}
case IPV6: {
return newEidBuilderLocal(Ipv6Afi.class, vni)
.setAddress(
- new Ipv6Builder().setIpv6(arrayToIpv6AddressNoZoneReversed(address))
+ new Ipv6Builder().setIpv6(arrayToIpv6AddressNoZone(address))
.build())
.build();
}
@@ -174,14 +174,14 @@ public interface EidTranslator extends AddressTranslator, EidMetadataProvider {
case IPV4: {
return newEidBuilderRemote(Ipv4Afi.class, vni)
.setAddress(
- new Ipv4Builder().setIpv4(arrayToIpv4AddressNoZoneReversed(address))
+ new Ipv4Builder().setIpv4(arrayToIpv4AddressNoZone(address))
.build())
.build();
}
case IPV6: {
return newEidBuilderRemote(Ipv6Afi.class, vni)
.setAddress(
- new Ipv6Builder().setIpv6(arrayToIpv6AddressNoZoneReversed(address))
+ new Ipv6Builder().setIpv6(arrayToIpv6AddressNoZone(address))
.build())
.build();
}
@@ -201,10 +201,10 @@ public interface EidTranslator extends AddressTranslator, EidMetadataProvider {
EidType type, byte[] address) {
switch (type) {
case IPV4: {
- return arrayToIpv4AddressNoZoneReversed(address).getValue();
+ return arrayToIpv4AddressNoZone(address).getValue();
}
case IPV6: {
- return arrayToIpv6AddressNoZoneReversed(address).getValue();
+ return arrayToIpv6AddressNoZone(address).getValue();
}
case MAC: {
//as wrong as it looks ,its right(second param is not end index,but count)
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocalMappingCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocalMappingCustomizerTest.java
index ba5639dc5..111a383dd 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocalMappingCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocalMappingCustomizerTest.java
@@ -131,7 +131,7 @@ public class LocalMappingCustomizerTest extends WriterCustomizerTest implements
assertNotNull(request);
assertEquals("Locator", new String(request.locatorSetName));
- assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.eid).getValue());
+ assertEquals("192.168.2.1", arrayToIpv4AddressNoZone(request.eid).getValue());
assertEquals(0, request.eidType);
assertEquals(1, request.isAdd);
assertEquals(25, request.vni);
@@ -154,7 +154,7 @@ public class LocalMappingCustomizerTest extends WriterCustomizerTest implements
assertNotNull(request);
assertEquals("Locator", new String(request.locatorSetName));
- assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.eid).getValue());
+ assertEquals("192.168.2.1", arrayToIpv4AddressNoZone(request.eid).getValue());
assertEquals(0, request.eidType);
assertEquals(0, request.isAdd);
assertEquals(25, request.vni);
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java
index e3239202f..c4dc869f3 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizerTest.java
@@ -74,7 +74,7 @@ public class MapResolverCustomizerTest extends WriterCustomizerTest implements I
LispAddDelMapResolver request = resolverCaptor.getValue();
assertEquals(1, request.isAdd);
- assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.ipAddress).getValue());
+ assertEquals("192.168.2.1", arrayToIpv4AddressNoZone(request.ipAddress).getValue());
}
@@ -97,7 +97,7 @@ public class MapResolverCustomizerTest extends WriterCustomizerTest implements I
LispAddDelMapResolver request = resolverCaptor.getValue();
assertEquals(0, request.isAdd);
- assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.ipAddress).getValue());
+ assertEquals("192.168.2.1", arrayToIpv4AddressNoZone(request.ipAddress).getValue());
}
}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RemoteMappingCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RemoteMappingCustomizerTest.java
index 538263ba4..8b31fa64f 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RemoteMappingCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/RemoteMappingCustomizerTest.java
@@ -109,8 +109,7 @@ public class RemoteMappingCustomizerTest extends WriterCustomizerTest implements
@Test(expected = NullPointerException.class)
public void testWriteCurrentAttributesBadData() throws WriteFailedException {
- customizer
- .writeCurrentAttributes(null, mock(RemoteMapping.class), writeContext);
+ customizer.writeCurrentAttributes(null, mock(RemoteMapping.class), writeContext);
}
@Test
@@ -123,7 +122,7 @@ public class RemoteMappingCustomizerTest extends WriterCustomizerTest implements
assertNotNull(request);
assertEquals(1, request.isAdd);
- assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.eid).getValue());
+ assertEquals("192.168.2.1", arrayToIpv4AddressNoZone(request.eid).getValue());
assertEquals(25, request.vni);
}
@@ -148,7 +147,7 @@ public class RemoteMappingCustomizerTest extends WriterCustomizerTest implements
assertNotNull(request);
assertEquals(0, request.isAdd);
- assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.eid).getValue());
+ assertEquals("192.168.2.1", arrayToIpv4AddressNoZone(request.eid).getValue());
assertEquals(25, request.vni);
}