summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'v3po/v3po2vpp/src/main/java')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/GreCustomizer.java31
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/VxlanCustomizer.java40
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/VxlanGpeCustomizer.java29
3 files changed, 34 insertions, 66 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/GreCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/GreCustomizer.java
index 2f6d4a51c..4e99c9397 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/GreCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/GreCustomizer.java
@@ -18,8 +18,8 @@ package io.fd.hc2vpp.v3po.interfaces;
import static com.google.common.base.Preconditions.checkArgument;
-import com.google.common.net.InetAddresses;
import io.fd.hc2vpp.common.translate.util.AbstractInterfaceTypeCustomizer;
+import io.fd.hc2vpp.common.translate.util.AddressTranslator;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteContext;
@@ -27,7 +27,6 @@ import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.GreAddDelTunnel;
import io.fd.vpp.jvpp.core.dto.GreAddDelTunnelReply;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
-import java.net.InetAddress;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone;
@@ -49,12 +48,13 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> implemen
this.interfaceContext = interfaceContext;
}
- private static GreAddDelTunnel getGreTunnelRequest(final byte isAdd, final byte[] srcAddr, final byte[] dstAddr,
- final int outerFibId, final byte isIpv6) {
+ private static GreAddDelTunnel getGreTunnelRequest(final byte isAdd, final IpAddressNoZone srcAddr,
+ final IpAddressNoZone dstAddr, final int outerFibId,
+ final byte isIpv6) {
final GreAddDelTunnel greAddDelTunnel = new GreAddDelTunnel();
greAddDelTunnel.isAdd = isAdd;
- greAddDelTunnel.srcAddress = srcAddr;
- greAddDelTunnel.dstAddress = dstAddr;
+ greAddDelTunnel.srcAddress = AddressTranslator.INSTANCE.ipAddressToArray(srcAddr);
+ greAddDelTunnel.dstAddress = AddressTranslator.INSTANCE.ipAddressToArray(dstAddr);
greAddDelTunnel.outerFibId = outerFibId;
greAddDelTunnel.isIpv6 = isIpv6;
return greAddDelTunnel;
@@ -87,15 +87,12 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> implemen
final byte isIpv6 = (byte) (isIpv6(gre)
? 1
: 0);
- final InetAddress srcAddress = InetAddresses.forString(getAddressString(gre.getSrc()));
- final InetAddress dstAddress = InetAddresses.forString(getAddressString(gre.getDst()));
-
int outerFibId = gre.getOuterFibId().intValue();
LOG.debug("Setting gre tunnel for interface: {}. Gre: {}", swIfName, gre);
final CompletionStage<GreAddDelTunnelReply> greAddDelTunnelReplyCompletionStage =
- getFutureJVpp().greAddDelTunnel(getGreTunnelRequest((byte) 1 /* is add */, srcAddress.getAddress(),
- dstAddress.getAddress(), outerFibId, isIpv6));
+ getFutureJVpp().greAddDelTunnel(getGreTunnelRequest((byte) 1 /* is add */, gre.getSrc(),
+ gre.getDst(), outerFibId, isIpv6));
final GreAddDelTunnelReply reply =
getReplyForCreate(greAddDelTunnelReplyCompletionStage.toCompletableFuture(), id, gre);
@@ -129,26 +126,18 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> implemen
}
}
- private String getAddressString(final IpAddressNoZone addr) {
- return addr.getIpv4AddressNoZone() == null
- ? addr.getIpv6AddressNoZone().getValue()
- : addr.getIpv4AddressNoZone().getValue();
- }
-
private void deleteGreTunnel(final InstanceIdentifier<Gre> id, final String swIfName, final Gre gre,
final WriteContext writeContext) throws WriteFailedException {
final byte isIpv6 = (byte) (isIpv6(gre)
? 1
: 0);
- final InetAddress srcAddress = InetAddresses.forString(getAddressString(gre.getSrc()));
- final InetAddress dstAddress = InetAddresses.forString(getAddressString(gre.getDst()));
int outerFibId = gre.getOuterFibId().intValue();
LOG.debug("Deleting gre tunnel for interface: {}. Gre: {}", swIfName, gre);
final CompletionStage<GreAddDelTunnelReply> greAddDelTunnelReplyCompletionStage =
- getFutureJVpp().greAddDelTunnel(getGreTunnelRequest((byte) 0 /* is add */, srcAddress.getAddress(),
- dstAddress.getAddress(), outerFibId, isIpv6));
+ getFutureJVpp().greAddDelTunnel(getGreTunnelRequest((byte) 0 /* is add */, gre.getSrc(),
+ gre.getDst(), outerFibId, isIpv6));
getReplyForDelete(greAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Gre tunnel deleted successfully for: {}, gre: {}", swIfName, gre);
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/VxlanCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/VxlanCustomizer.java
index b0387d1b6..5d5b086ec 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/VxlanCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/VxlanCustomizer.java
@@ -18,8 +18,8 @@ package io.fd.hc2vpp.v3po.interfaces;
import static com.google.common.base.Preconditions.checkArgument;
-import com.google.common.net.InetAddresses;
import io.fd.hc2vpp.common.translate.util.AbstractInterfaceTypeCustomizer;
+import io.fd.hc2vpp.common.translate.util.AddressTranslator;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.hc2vpp.v3po.DisabledInterfacesManager;
@@ -28,7 +28,6 @@ import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.VxlanAddDelTunnel;
import io.fd.vpp.jvpp.core.dto.VxlanAddDelTunnelReply;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
-import java.net.InetAddress;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone;
@@ -82,10 +81,8 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> impl
final WriteContext writeContext)
throws WriteFailedException {
final byte isIpv6 = (byte) (isIpv6(vxlan)
- ? 1
- : 0);
- final InetAddress srcAddress = InetAddresses.forString(getAddressString(vxlan.getSrc()));
- final InetAddress dstAddress = InetAddresses.forString(getAddressString(vxlan.getDst()));
+ ? 1
+ : 0);
checkArgument(vxlan.getEncapVrfId() != null && vxlan.getEncapVrfId().getValue() != null,
"encap-vrf-id is mandatory but was not given");
@@ -101,8 +98,8 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> impl
LOG.debug("Setting vxlan tunnel for interface: {}. Vxlan: {}", swIfName, vxlan);
final CompletionStage<VxlanAddDelTunnelReply> vxlanAddDelTunnelReplyCompletionStage =
- getFutureJVpp().vxlanAddDelTunnel(getVxlanTunnelRequest((byte) 1 /* is add */, srcAddress.getAddress(),
- dstAddress.getAddress(), encapVrfId, decapNext, vni, isIpv6));
+ getFutureJVpp().vxlanAddDelTunnel(getVxlanTunnelRequest((byte) 1 /* is add */, vxlan.getSrc(),
+ vxlan.getDst(), encapVrfId, decapNext, vni, isIpv6));
final VxlanAddDelTunnelReply reply =
getReplyForCreate(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id, vxlan);
@@ -145,19 +142,11 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> impl
}
}
- private String getAddressString(final IpAddressNoZone addr) {
- return addr.getIpv4AddressNoZone() == null
- ? addr.getIpv6AddressNoZone().getValue()
- : addr.getIpv4AddressNoZone().getValue();
- }
-
private void deleteVxlanTunnel(final InstanceIdentifier<Vxlan> id, final String swIfName, final Vxlan vxlan,
final WriteContext writeContext) throws WriteFailedException {
final byte isIpv6 = (byte) (isIpv6(vxlan)
- ? 1
- : 0);
- final InetAddress srcAddress = InetAddresses.forString(getAddressString(vxlan.getSrc()));
- final InetAddress dstAddress = InetAddresses.forString(getAddressString(vxlan.getDst()));
+ ? 1
+ : 0);
checkArgument(vxlan.getEncapVrfId() != null && vxlan.getEncapVrfId().getValue() != null,
"encap-vrf-id is mandatory but was not given");
@@ -173,8 +162,8 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> impl
LOG.debug("Deleting vxlan tunnel for interface: {}. Vxlan: {}", swIfName, vxlan);
final CompletionStage<VxlanAddDelTunnelReply> vxlanAddDelTunnelReplyCompletionStage =
- getFutureJVpp().vxlanAddDelTunnel(getVxlanTunnelRequest((byte) 0 /* is add */, srcAddress.getAddress(),
- dstAddress.getAddress(), encapVrfId, decapNext, vni, isIpv6));
+ getFutureJVpp().vxlanAddDelTunnel(getVxlanTunnelRequest((byte) 0 /* is add */, vxlan.getSrc(),
+ vxlan.getDst(), encapVrfId, decapNext, vni, isIpv6));
getReplyForDelete(vxlanAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
LOG.debug("Vxlan tunnel deleted successfully for: {}, vxlan: {}", swIfName, vxlan);
@@ -188,13 +177,14 @@ public class VxlanCustomizer extends AbstractInterfaceTypeCustomizer<Vxlan> impl
interfaceNamingContext.removeName(swIfName, writeContext.getMappingContext());
}
- private static VxlanAddDelTunnel getVxlanTunnelRequest(final byte isAdd, final byte[] srcAddr, final byte[] dstAddr,
- final int encapVrfId,
- final int decapNextIndex, final int vni, final byte isIpv6) {
+ private static VxlanAddDelTunnel getVxlanTunnelRequest(final byte isAdd, final IpAddressNoZone srcAddr,
+ final IpAddressNoZone dstAddr,
+ final int encapVrfId,
+ final int decapNextIndex, final int vni, final byte isIpv6) {
final VxlanAddDelTunnel vxlanAddDelTunnel = new VxlanAddDelTunnel();
vxlanAddDelTunnel.isAdd = isAdd;
- vxlanAddDelTunnel.srcAddress = srcAddr;
- vxlanAddDelTunnel.dstAddress = dstAddr;
+ vxlanAddDelTunnel.srcAddress = AddressTranslator.INSTANCE.ipAddressToArray(srcAddr);
+ vxlanAddDelTunnel.dstAddress = AddressTranslator.INSTANCE.ipAddressToArray(dstAddr);
vxlanAddDelTunnel.encapVrfId = encapVrfId;
vxlanAddDelTunnel.vni = vni;
vxlanAddDelTunnel.decapNextIndex = decapNextIndex;
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/VxlanGpeCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/VxlanGpeCustomizer.java
index ac21c4dbd..c875b87dc 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/VxlanGpeCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/VxlanGpeCustomizer.java
@@ -18,8 +18,8 @@ package io.fd.hc2vpp.v3po.interfaces;
import static com.google.common.base.Preconditions.checkArgument;
-import com.google.common.net.InetAddresses;
import io.fd.hc2vpp.common.translate.util.AbstractInterfaceTypeCustomizer;
+import io.fd.hc2vpp.common.translate.util.AddressTranslator;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.hc2vpp.v3po.DisabledInterfacesManager;
@@ -28,7 +28,6 @@ import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.VxlanGpeAddDelTunnel;
import io.fd.vpp.jvpp.core.dto.VxlanGpeAddDelTunnelReply;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
-import java.net.InetAddress;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone;
@@ -83,8 +82,6 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
final byte isIpv6 = (byte) (isIpv6(vxlanGpe)
? 1
: 0);
- final InetAddress Local = InetAddresses.forString(getAddressString(vxlanGpe.getLocal()));
- final InetAddress Remote = InetAddresses.forString(getAddressString(vxlanGpe.getRemote()));
int vni = vxlanGpe.getVni().getValue().intValue();
byte protocol = (byte) vxlanGpe.getNextProtocol().getIntValue();
@@ -93,8 +90,8 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
LOG.debug("Setting VxlanGpe tunnel for interface: {}. VxlanGpe: {}", swIfName, vxlanGpe);
final CompletionStage<VxlanGpeAddDelTunnelReply> VxlanGpeAddDelTunnelReplyCompletionStage =
- getFutureJVpp().vxlanGpeAddDelTunnel(getVxlanGpeTunnelRequest((byte) 1 /* is add */, Local.getAddress(),
- Remote.getAddress(), vni, protocol, encapVrfId, decapVrfId, isIpv6));
+ getFutureJVpp().vxlanGpeAddDelTunnel(getVxlanGpeTunnelRequest((byte) 1 /* is add */, vxlanGpe.getLocal(),
+ vxlanGpe.getRemote(), vni, protocol, encapVrfId, decapVrfId, isIpv6));
final VxlanGpeAddDelTunnelReply reply =
getReplyForCreate(VxlanGpeAddDelTunnelReplyCompletionStage.toCompletableFuture(), id, vxlanGpe);
@@ -131,20 +128,12 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
}
}
- private String getAddressString(final IpAddressNoZone addr) {
- return addr.getIpv4AddressNoZone() == null
- ? addr.getIpv6AddressNoZone().getValue()
- : addr.getIpv4AddressNoZone().getValue();
- }
-
private void deleteVxlanGpeTunnel(final InstanceIdentifier<VxlanGpe> id, final String swIfName,
final VxlanGpe vxlanGpe, final WriteContext writeContext)
throws WriteFailedException {
final byte isIpv6 = (byte) (isIpv6(vxlanGpe)
? 1
: 0);
- final InetAddress local = InetAddresses.forString(getAddressString(vxlanGpe.getLocal()));
- final InetAddress remote = InetAddresses.forString(getAddressString(vxlanGpe.getRemote()));
int vni = vxlanGpe.getVni().getValue().intValue();
byte protocol = (byte) vxlanGpe.getNextProtocol().getIntValue();
@@ -154,8 +143,8 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
LOG.debug("Deleting VxlanGpe tunnel for interface: {}. VxlanGpe: {}", swIfName, vxlanGpe);
final CompletionStage<VxlanGpeAddDelTunnelReply> VxlanGpeAddDelTunnelReplyCompletionStage =
getFutureJVpp()
- .vxlanGpeAddDelTunnel(getVxlanGpeTunnelRequest((byte) 0 /* is delete */, local.getAddress(),
- remote.getAddress(), vni, protocol, encapVrfId, decapVrfId, isIpv6));
+ .vxlanGpeAddDelTunnel(getVxlanGpeTunnelRequest((byte) 0 /* is delete */, vxlanGpe.getLocal(),
+ vxlanGpe.getRemote(), vni, protocol, encapVrfId, decapVrfId, isIpv6));
getReplyForDelete(VxlanGpeAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
final int index = interfaceNamingContext.getIndex(swIfName, writeContext.getMappingContext());
// Mark this interface as disabled to not include it in operational reads
@@ -166,15 +155,15 @@ public class VxlanGpeCustomizer extends AbstractInterfaceTypeCustomizer<VxlanGpe
interfaceNamingContext.removeName(swIfName, writeContext.getMappingContext());
}
- private static VxlanGpeAddDelTunnel getVxlanGpeTunnelRequest(final byte isAdd, final byte[] local,
- final byte[] remote,
+ private static VxlanGpeAddDelTunnel getVxlanGpeTunnelRequest(final byte isAdd, final IpAddressNoZone local,
+ final IpAddressNoZone remote,
final int vni, final byte protocol,
final int encapVrfId, final int decapVrfId,
final byte isIpv6) {
final VxlanGpeAddDelTunnel VxlanGpeAddDelTunnel = new VxlanGpeAddDelTunnel();
VxlanGpeAddDelTunnel.isAdd = isAdd;
- VxlanGpeAddDelTunnel.local = local;
- VxlanGpeAddDelTunnel.remote = remote;
+ VxlanGpeAddDelTunnel.local = AddressTranslator.INSTANCE.ipAddressToArray(local);
+ VxlanGpeAddDelTunnel.remote = AddressTranslator.INSTANCE.ipAddressToArray(remote);
VxlanGpeAddDelTunnel.vni = vni;
VxlanGpeAddDelTunnel.protocol = protocol;
VxlanGpeAddDelTunnel.encapVrfId = encapVrfId;