summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/util/EidTranslator.java18
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/GreCustomizerTest.java9
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizerTest.java9
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanGpeCustomizerTest.java9
-rw-r--r--vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/Ipv6Translator.java23
5 files changed, 17 insertions, 51 deletions
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 c8e868086..039aa1bf9 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
@@ -18,6 +18,7 @@ package io.fd.hc2vpp.lisp.translate.util;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.net.InetAddresses.forString;
import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType;
import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV4;
import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV4_PREFIX;
@@ -25,12 +26,9 @@ import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDump
import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV6_PREFIX;
import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.MAC;
import static java.lang.Integer.parseInt;
-import static java.lang.String.format;
import inet.ipaddr.IPAddress;
import io.fd.hc2vpp.common.translate.util.AddressTranslator;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
import java.util.Arrays;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
@@ -200,7 +198,7 @@ public interface EidTranslator extends AddressTranslator, EidMetadataProvider {
static String prefixValue(final String prefix, final String suffix) {
// normalize prefix based address to prevent duplicates
- IPAddress normalizedForm = IPAddress.from(getAddress(prefix)).toSubnet(parseInt(suffix));
+ IPAddress normalizedForm = IPAddress.from(forString(prefix)).toSubnet(parseInt(suffix));
return normalizedForm.toCompressedString();
}
@@ -601,9 +599,9 @@ public interface EidTranslator extends AddressTranslator, EidMetadataProvider {
final String[] secondPrefixParts = getPrefixParts(secondPrefix);
IPAddress firstAddress =
- IPAddress.from(getAddress(firstPrefixParts[0])).toSubnet(parseInt(firstPrefixParts[1]));
+ IPAddress.from(forString(firstPrefixParts[0])).toSubnet(parseInt(firstPrefixParts[1]));
IPAddress secondAddress =
- IPAddress.from(getAddress(secondPrefixParts[0])).toSubnet(parseInt(secondPrefixParts[1]));
+ IPAddress.from(forString(secondPrefixParts[0])).toSubnet(parseInt(secondPrefixParts[1]));
return firstAddress.compareTo(secondAddress) == 0;
}
@@ -613,12 +611,4 @@ public interface EidTranslator extends AddressTranslator, EidMetadataProvider {
checkArgument(split.length == 2, "%s is not a valid ip prefix", prefixString);
return split;
}
-
- static InetAddress getAddress(final String value) {
- try {
- return InetAddress.getByName(value);
- } catch (UnknownHostException e) {
- throw new IllegalArgumentException(format("Unable to convert %s", value), e);
- }
- }
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/GreCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/GreCustomizerTest.java
index 806da6858..fe0429b2b 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/GreCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/GreCustomizerTest.java
@@ -26,6 +26,7 @@ import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import com.google.common.collect.Lists;
+import com.google.common.net.InetAddresses;
import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest;
import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.hc2vpp.v3po.interfacesstate.cache.InterfaceCacheDumpManager;
@@ -36,8 +37,6 @@ import io.fd.vpp.jvpp.core.dto.GreTunnelDetails;
import io.fd.vpp.jvpp.core.dto.GreTunnelDetailsReplyDump;
import io.fd.vpp.jvpp.core.dto.GreTunnelDump;
import io.fd.vpp.jvpp.core.dto.SwInterfaceDetails;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
@@ -68,7 +67,7 @@ public class GreCustomizerTest extends ReaderCustomizerTest<Gre, GreBuilder> {
}
@Override
- public void setUp() throws UnknownHostException, VppInvocationException, ReadFailedException {
+ public void setUp() throws VppInvocationException, ReadFailedException {
interfacesContext = new NamingContext("gre-tunnel", IFC_CTX_NAME);
defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
@@ -80,8 +79,8 @@ public class GreCustomizerTest extends ReaderCustomizerTest<Gre, GreBuilder> {
final GreTunnelDetailsReplyDump value = new GreTunnelDetailsReplyDump();
final GreTunnelDetails greTunnelDetails = new GreTunnelDetails();
greTunnelDetails.isIpv6 = 0;
- greTunnelDetails.dstAddress = InetAddress.getByName("1.2.3.4").getAddress();
- greTunnelDetails.srcAddress = InetAddress.getByName("1.2.3.5").getAddress();
+ greTunnelDetails.dstAddress = InetAddresses.forString("1.2.3.4").getAddress();
+ greTunnelDetails.srcAddress = InetAddresses.forString("1.2.3.5").getAddress();
greTunnelDetails.outerFibId = 55;
greTunnelDetails.swIfIndex = 0;
value.greTunnelDetails = Lists.newArrayList(greTunnelDetails);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizerTest.java
index ba0cf2d2d..bfeb7eaa9 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanCustomizerTest.java
@@ -26,6 +26,7 @@ import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import com.google.common.collect.Lists;
+import com.google.common.net.InetAddresses;
import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest;
import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.hc2vpp.v3po.interfacesstate.cache.InterfaceCacheDumpManager;
@@ -36,8 +37,6 @@ import io.fd.vpp.jvpp.core.dto.SwInterfaceDetails;
import io.fd.vpp.jvpp.core.dto.VxlanTunnelDetails;
import io.fd.vpp.jvpp.core.dto.VxlanTunnelDetailsReplyDump;
import io.fd.vpp.jvpp.core.dto.VxlanTunnelDump;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
@@ -69,7 +68,7 @@ public class VxlanCustomizerTest extends ReaderCustomizerTest<Vxlan, VxlanBuilde
}
@Override
- public void setUp() throws UnknownHostException, VppInvocationException, ReadFailedException {
+ public void setUp() throws VppInvocationException, ReadFailedException {
interfacesContext = new NamingContext("vxlan-tunnel", IFC_CTX_NAME);
defineMapping(mappingContext, IF_NAME, IF_INDEX, IFC_CTX_NAME);
@@ -81,8 +80,8 @@ public class VxlanCustomizerTest extends ReaderCustomizerTest<Vxlan, VxlanBuilde
final VxlanTunnelDetailsReplyDump value = new VxlanTunnelDetailsReplyDump();
final VxlanTunnelDetails vxlanTunnelDetails = new VxlanTunnelDetails();
vxlanTunnelDetails.isIpv6 = 0;
- vxlanTunnelDetails.dstAddress = InetAddress.getByName("1.2.3.4").getAddress();
- vxlanTunnelDetails.srcAddress = InetAddress.getByName("1.2.3.5").getAddress();
+ vxlanTunnelDetails.dstAddress = InetAddresses.forString("1.2.3.4").getAddress();
+ vxlanTunnelDetails.srcAddress = InetAddresses.forString("1.2.3.5").getAddress();
vxlanTunnelDetails.encapVrfId = 55;
vxlanTunnelDetails.swIfIndex = 0;
vxlanTunnelDetails.vni = 9;
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanGpeCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanGpeCustomizerTest.java
index ce794302b..6eafa268d 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanGpeCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VxlanGpeCustomizerTest.java
@@ -27,6 +27,7 @@ import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import com.google.common.collect.Lists;
+import com.google.common.net.InetAddresses;
import io.fd.hc2vpp.common.test.read.ReaderCustomizerTest;
import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.hc2vpp.v3po.interfacesstate.cache.InterfaceCacheDumpManager;
@@ -37,8 +38,6 @@ import io.fd.vpp.jvpp.core.dto.SwInterfaceDetails;
import io.fd.vpp.jvpp.core.dto.VxlanGpeTunnelDetails;
import io.fd.vpp.jvpp.core.dto.VxlanGpeTunnelDetailsReplyDump;
import io.fd.vpp.jvpp.core.dto.VxlanGpeTunnelDump;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
@@ -69,7 +68,7 @@ public class VxlanGpeCustomizerTest extends ReaderCustomizerTest<VxlanGpe, Vxlan
}
@Override
- public void setUp() throws UnknownHostException, VppBaseCallException, ReadFailedException {
+ public void setUp() throws VppBaseCallException, ReadFailedException {
interfacesContext = new NamingContext("vxlan_gpe_inf", IFC_CTX_NAME);
defineMapping(mappingContext, IF_NAME, IF_INDEX, IFC_CTX_NAME);
@@ -81,8 +80,8 @@ public class VxlanGpeCustomizerTest extends ReaderCustomizerTest<VxlanGpe, Vxlan
final VxlanGpeTunnelDetailsReplyDump value = new VxlanGpeTunnelDetailsReplyDump();
final VxlanGpeTunnelDetails vxlanGpeTunnelDetails = new VxlanGpeTunnelDetails();
vxlanGpeTunnelDetails.isIpv6 = 0;
- vxlanGpeTunnelDetails.local = InetAddress.getByName("1.2.3.4").getAddress();
- vxlanGpeTunnelDetails.remote = InetAddress.getByName("1.2.3.5").getAddress();
+ vxlanGpeTunnelDetails.local = InetAddresses.forString("1.2.3.4").getAddress();
+ vxlanGpeTunnelDetails.remote = InetAddresses.forString("1.2.3.5").getAddress();
vxlanGpeTunnelDetails.vni = 9;
vxlanGpeTunnelDetails.protocol = 1;
vxlanGpeTunnelDetails.encapVrfId = 55;
diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/Ipv6Translator.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/Ipv6Translator.java
index d2f046302..6a71d6af2 100644
--- a/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/Ipv6Translator.java
+++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/Ipv6Translator.java
@@ -43,17 +43,7 @@ public interface Ipv6Translator extends ByteDataTranslator {
* @return byte array with address bytes
*/
default byte[] ipv6AddressNoZoneToArray(@Nonnull final Ipv6Address address) {
- return Impl.ipv6AddressNoZoneToArray(address.getValue());
- }
-
- /**
- * Transform Ipv6 address to a byte array acceptable by VPP. VPP expects incoming byte array to be in the same order
- * as the address.
- *
- * @return byte array with address bytes
- */
- default byte[] ipv6AddressNoZoneToArray(@Nonnull final Ipv6AddressNoZone ipv6Addr) {
- return Impl.ipv6AddressNoZoneToArray(ipv6Addr.getValue());
+ return InetAddresses.forString(address.getValue()).getAddress();
}
/**
@@ -138,15 +128,4 @@ public interface Ipv6Translator extends ByteDataTranslator {
"Cannot create prefix for address[" + Arrays.toString(address) + "],prefix[" + prefix + "]", e);
}
}
-
- class Impl {
- private static byte[] ipv6AddressNoZoneToArray(@Nonnull final String address){
- try {
- // No lookup performed for literal ipv6 addresses
- return InetAddress.getByName(address).getAddress();
- } catch (UnknownHostException e) {
- throw new IllegalArgumentException("Invalid address supplied", e);
- }
- }
- }
}