summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/read/IpsecStateSpdCustomizer.java73
-rw-r--r--ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/IpsecSadEntryCustomizer.java129
-rw-r--r--ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/IpsecSpdCustomizer.java48
-rw-r--r--ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/read/IpsecStateSpdCustomizerTest.java30
-rw-r--r--ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/IpsecSadEntryCustomizerTest.java120
-rw-r--r--ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/IpsecSpdCustomizerTest.java55
-rw-r--r--l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv4/Ipv4NeighbourCustomizer.java14
-rw-r--r--l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv4/subinterface/SubInterfaceIpv4NeighbourCustomizer.java11
-rw-r--r--l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv6/Ipv6NeighbourCustomizer.java14
-rw-r--r--l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv6/nd/NdProxyCustomizer.java2
-rw-r--r--l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv6/subinterface/SubInterfaceIpv6NeighbourCustomizer.java11
-rw-r--r--l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv4/Ipv4NeighbourCustomizer.java16
-rw-r--r--l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv4/ProxyRangeCustomizer.java9
-rw-r--r--l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv4/subinterface/SubInterfaceIpv4NeighbourCustomizer.java16
-rw-r--r--l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6NeighbourCustomizer.java26
-rw-r--r--l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/nd/NdProxyCustomizer.java4
-rw-r--r--l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/subinterface/SubInterfaceIpv6NeighbourCustomizer.java18
-rw-r--r--l3/impl/src/test/java/io/fd/hc2vpp/l3/read/InterfaceChildNodeTest.java27
-rw-r--r--l3/impl/src/test/java/io/fd/hc2vpp/l3/read/ipv6/nd/NdProxyCustomizerTest.java10
-rw-r--r--l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ProxyRangeCustomizerTest.java9
-rw-r--r--l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ipv4/Ipv4NeighbourCustomizerTest.java23
-rw-r--r--l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6NeighbourCustomizerTest.java23
-rw-r--r--l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ipv6/nd/NdProxyCustomizerTest.java7
-rw-r--r--l3/utils/src/main/java/io/fd/hc2vpp/l3/utils/ip/write/IpWriter.java22
-rw-r--r--routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/PrefixCustomizer.java3
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/PrefixCustomizerTest.java34
-rw-r--r--vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/Ipv4Translator.java33
-rw-r--r--vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/Ipv6Translator.java39
-rw-r--r--vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/MacTranslator.java17
29 files changed, 534 insertions, 309 deletions
diff --git a/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/read/IpsecStateSpdCustomizer.java b/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/read/IpsecStateSpdCustomizer.java
index 45f54cdb8..a9a20cff0 100644
--- a/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/read/IpsecStateSpdCustomizer.java
+++ b/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/read/IpsecStateSpdCustomizer.java
@@ -17,7 +17,6 @@
package io.fd.hc2vpp.ipsec.read;
import com.google.common.base.Optional;
-import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
import io.fd.hc2vpp.common.translate.util.Ipv6Translator;
@@ -35,6 +34,7 @@ import io.fd.vpp.jvpp.core.dto.IpsecSpdsDetails;
import io.fd.vpp.jvpp.core.dto.IpsecSpdsDetailsReplyDump;
import io.fd.vpp.jvpp.core.dto.IpsecSpdsDump;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import io.fd.vpp.jvpp.core.types.AddressFamily;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
@@ -134,23 +134,22 @@ public class IpsecStateSpdCustomizer extends FutureJVppCustomizer
private SpdEntries translateDetailToEntry(final IpsecSpdDetails details) {
SpdEntriesBuilder builder = new SpdEntriesBuilder();
- builder.setDirection(IpsecTrafficDirection.forValue(details.isOutbound))
- .setIsIpv6(ByteDataTranslator.INSTANCE.byteToBoolean(details.isIpv6))
- .setPriority(details.priority);
- switch (details.policy) {
- case 0:
+ builder.setDirection(IpsecTrafficDirection.forValue(details.entry.isOutbound))
+ .setPriority(details.entry.priority);
+ switch (details.entry.policy) {
+ case IPSEC_API_SPD_ACTION_BYPASS:
builder.setOperation(IpsecSpdOperation.Bypass);
break;
- case 1:
+ case IPSEC_API_SPD_ACTION_DISCARD:
builder.setOperation(IpsecSpdOperation.Discard);
break;
- case 3:
+ case IPSEC_API_SPD_ACTION_PROTECT:
builder.setOperation(IpsecSpdOperation.Protect);
- builder.setProtectSaId(details.saId);
+ builder.setProtectSaId(details.entry.saId);
break;
}
- if (builder.isIsIpv6()) {
+ if (details.entry.localAddressStart != null && details.entry.localAddressStart.af.equals(AddressFamily.ADDRESS_IP6)) {
processIpv6AddressRanges(builder, details);
} else {
processIpv4AddressRanges(builder, details);
@@ -160,40 +159,62 @@ public class IpsecStateSpdCustomizer extends FutureJVppCustomizer
}
private void processIpv4AddressRanges(final SpdEntriesBuilder builder, final IpsecSpdDetails details) {
- if (details.localStartAddr != null && details.localStartAddr.length > 0) {
+ if (details.entry.localAddressStart != null &&
+ details.entry.localAddressStart.un.getIp4().ip4Address.length > 0) {
builder.setLaddrStart(IpAddressBuilder.getDefaultInstance(
- new IpAddressNoZone(arrayToIpv4AddressNoZone(details.localStartAddr)).stringValue()));
+ new IpAddressNoZone(
+ arrayToIpv4AddressNoZone(details.entry.localAddressStart.un.getIp4().ip4Address))
+ .stringValue()));
}
- if (details.localStopAddr != null && details.localStopAddr.length > 0) {
+ if (details.entry.localAddressStop != null &&
+ details.entry.localAddressStop.un.getIp4().ip4Address.length > 0) {
builder.setLaddrStop(IpAddressBuilder.getDefaultInstance(
- new IpAddressNoZone(arrayToIpv4AddressNoZone(details.localStopAddr)).stringValue()));
+ new IpAddressNoZone(arrayToIpv4AddressNoZone(details.entry.localAddressStop.un.getIp4().ip4Address))
+ .stringValue()));
}
- if (details.remoteStartAddr != null && details.remoteStartAddr.length > 0) {
+ if (details.entry.remoteAddressStart != null &&
+ details.entry.remoteAddressStart.un.getIp4().ip4Address.length > 0) {
builder.setRaddrStart(IpAddressBuilder.getDefaultInstance(
- new IpAddressNoZone(arrayToIpv4AddressNoZone(details.remoteStartAddr)).stringValue()));
+ new IpAddressNoZone(
+ arrayToIpv4AddressNoZone(details.entry.remoteAddressStart.un.getIp4().ip4Address))
+ .stringValue()));
}
- if (details.remoteStopAddr != null && details.remoteStopAddr.length > 0) {
+ if (details.entry.remoteAddressStop != null &&
+ details.entry.remoteAddressStop.un.getIp4().ip4Address.length > 0) {
builder.setRaddrStop(IpAddressBuilder.getDefaultInstance(
- new IpAddressNoZone(arrayToIpv4AddressNoZone(details.remoteStopAddr)).stringValue()));
+ new IpAddressNoZone(
+ arrayToIpv4AddressNoZone(details.entry.remoteAddressStop.un.getIp4().ip4Address))
+ .stringValue()));
}
}
private void processIpv6AddressRanges(final SpdEntriesBuilder builder, final IpsecSpdDetails details) {
- if (details.localStartAddr != null && details.localStartAddr.length > 0) {
+ if (details.entry.localAddressStart != null &&
+ details.entry.localAddressStart.un.getIp6().ip6Address.length > 0) {
builder.setLaddrStart(IpAddressBuilder.getDefaultInstance(
- new IpAddressNoZone(arrayToIpv6AddressNoZone(details.localStartAddr)).stringValue()));
+ new IpAddressNoZone(
+ arrayToIpv6AddressNoZone(details.entry.localAddressStart.un.getIp6().ip6Address))
+ .stringValue()));
}
- if (details.localStopAddr != null && details.localStopAddr.length > 0) {
+ if (details.entry.localAddressStop != null &&
+ details.entry.localAddressStop.un.getIp6().ip6Address.length > 0) {
builder.setLaddrStop(IpAddressBuilder.getDefaultInstance(
- new IpAddressNoZone(arrayToIpv6AddressNoZone(details.localStopAddr)).stringValue()));
+ new IpAddressNoZone(arrayToIpv6AddressNoZone(details.entry.localAddressStop.un.getIp6().ip6Address))
+ .stringValue()));
}
- if (details.remoteStartAddr != null && details.remoteStartAddr.length > 0) {
+ if (details.entry.remoteAddressStart != null &&
+ details.entry.remoteAddressStart.un.getIp6().ip6Address.length > 0) {
builder.setRaddrStart(IpAddressBuilder.getDefaultInstance(
- new IpAddressNoZone(arrayToIpv6AddressNoZone(details.remoteStartAddr)).stringValue()));
+ new IpAddressNoZone(
+ arrayToIpv6AddressNoZone(details.entry.remoteAddressStart.un.getIp6().ip6Address))
+ .stringValue()));
}
- if (details.remoteStopAddr != null && details.remoteStopAddr.length > 0) {
+ if (details.entry.remoteAddressStop != null &&
+ details.entry.remoteAddressStop.un.getIp6().ip6Address.length > 0) {
builder.setRaddrStop(IpAddressBuilder.getDefaultInstance(
- new IpAddressNoZone(arrayToIpv6AddressNoZone(details.remoteStopAddr)).stringValue()));
+ new IpAddressNoZone(
+ arrayToIpv6AddressNoZone(details.entry.remoteAddressStop.un.getIp6().ip6Address))
+ .stringValue()));
}
}
diff --git a/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/IpsecSadEntryCustomizer.java b/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/IpsecSadEntryCustomizer.java
index c29137d26..1822b024f 100644
--- a/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/IpsecSadEntryCustomizer.java
+++ b/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/IpsecSadEntryCustomizer.java
@@ -25,12 +25,19 @@ import io.fd.hc2vpp.common.translate.util.MultiNamingContext;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import io.fd.vpp.jvpp.core.dto.IpsecSadAddDelEntry;
-import io.fd.vpp.jvpp.core.dto.IpsecSadAddDelEntryReply;
+import io.fd.vpp.jvpp.core.dto.IpsecSadEntryAddDel;
+import io.fd.vpp.jvpp.core.dto.IpsecSadEntryAddDelReply;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import io.fd.vpp.jvpp.core.types.IpsecCryptoAlg;
+import io.fd.vpp.jvpp.core.types.IpsecIntegAlg;
+import io.fd.vpp.jvpp.core.types.IpsecProto;
+import io.fd.vpp.jvpp.core.types.IpsecSadEntry;
+import io.fd.vpp.jvpp.core.types.IpsecSadFlags;
+import io.fd.vpp.jvpp.core.types.Key;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.ipsec.rev181213.IpsecSadEntriesAugmentation;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipsec.rev181214.IpsecMode;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipsec.rev181214.ip.address.grouping.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipsec.rev181214.ip.address.grouping.ip.address.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipsec.rev181214.ip.address.grouping.ip.address.Ipv6Address;
@@ -87,44 +94,54 @@ public class IpsecSadEntryCustomizer extends FutureJVppCustomizer
private void addDelEntry(final InstanceIdentifier<SadEntries> id,
final SadEntries dataAfter,
final WriteContext writeContext, boolean adding) throws WriteFailedException {
- final IpsecSadAddDelEntry entry = new IpsecSadAddDelEntry();
+ final IpsecSadEntryAddDel request = new IpsecSadEntryAddDel();
+ request.entry = new IpsecSadEntry();
IpsecSadEntriesAugmentation augment = dataAfter.augmentation(IpsecSadEntriesAugmentation.class);
if (augment != null && augment.getSaId() != null) {
- entry.sadId = augment.getSaId();
+ request.entry.sadId = augment.getSaId();
}
if (dataAfter.getSpi() != null) {
- entry.spi = dataAfter.getSpi().intValue();
+ request.entry.spi = dataAfter.getSpi().intValue();
}
- if (dataAfter.getAntiReplayWindow() != null) {
- entry.useAntiReplay = dataAfter.getAntiReplayWindow() > 0
- ? BYTE_TRUE
- : BYTE_FALSE;
+ request.entry.flags = IpsecSadFlags.IPSEC_API_SAD_FLAG_NONE;
+ if (dataAfter.getAntiReplayWindow() != null && dataAfter.getAntiReplayWindow() > 0) {
+ request.entry.flags = IpsecSadFlags.IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY;
}
- if (dataAfter.getSaMode() != null) {
- entry.isTunnel = Integer.valueOf(dataAfter.getSaMode().getIntValue()).byteValue();
+ if (dataAfter.getSaMode() != null && dataAfter.getSaMode().equals(IpsecMode.Tunnel)) {
+ //TODO check if flags can be set at once
+ if (dataAfter.getSourceAddress() != null &&
+ dataAfter.getSourceAddress().getIpAddress() instanceof Ipv4Address) {
+ request.entry.flags = IpsecSadFlags
+ .forValue((request.entry.flags.value + IpsecSadFlags.IPSEC_API_SAD_FLAG_IS_TUNNEL.value));
+ } else if (dataAfter.getSourceAddress() != null &&
+ dataAfter.getSourceAddress().getIpAddress() instanceof Ipv6Address) {
+ request.entry.flags = IpsecSadFlags
+ .forValue((request.entry.flags.value + IpsecSadFlags.IPSEC_API_SAD_FLAG_IS_TUNNEL_V6.value));
+ }
}
- entry.isAdd = adding
+ request.isAdd = adding
? ByteDataTranslator.BYTE_TRUE
: ByteDataTranslator.BYTE_FALSE;
if (dataAfter.getEsp() != null) {
- entry.protocol = 1;
- fillEspAuthentication(entry, dataAfter.getEsp());
- fillEspEncryption(entry, dataAfter.getEsp());
+ request.entry.protocol = IpsecProto.IPSEC_API_PROTO_ESP;
+ fillEspAuthentication(request, dataAfter.getEsp());
+ fillEspEncryption(request, dataAfter.getEsp());
} else if (dataAfter.getAh() != null) {
- entry.protocol = 0;
- fillAhAuthentication(entry, dataAfter.getAh());
+ request.entry.protocol = IpsecProto.IPSEC_API_PROTO_AH;
+ fillAhAuthentication(request, dataAfter.getAh());
+ fillAhEncryption(request, dataAfter.getAh());
}
- fillAddresses(entry, dataAfter);
+ fillAddresses(request, dataAfter);
- LOG.debug("IPSec config change id={} request={}", id, entry);
- final CompletionStage<IpsecSadAddDelEntryReply> ipsecSadEntryAddDellReplyFuture =
- getFutureJVpp().ipsecSadAddDelEntry(entry);
+ LOG.debug("IPSec config change id={} request={}", id, request);
+ final CompletionStage<IpsecSadEntryAddDelReply> ipsecSadEntryAddDellReplyFuture =
+ getFutureJVpp().ipsecSadEntryAddDel(request);
getReplyForWrite(ipsecSadEntryAddDellReplyFuture.toCompletableFuture(), id);
if (adding) {
- sadEntryMapping.addChild(dataAfter.key().getDirection().getName(), entry.sadId,
+ sadEntryMapping.addChild(dataAfter.key().getDirection().getName(), request.entry.sadId,
String.valueOf(dataAfter.key().getSpi()), writeContext.getMappingContext());
} else {
sadEntryMapping
@@ -133,7 +150,7 @@ public class IpsecSadEntryCustomizer extends FutureJVppCustomizer
}
}
- private void fillAhAuthentication(IpsecSadAddDelEntry targetEntry, Ah data) {
+ private void fillAhAuthentication(IpsecSadEntryAddDel request, Ah data) {
//0 = None, 1 = MD5-96, 2 = SHA1-96, 3 = SHA-256, 4 = SHA-384, 5=SHA-512
AuthenticationAlgorithm authAlg = data.getAuthenticationAlgorithm();
if (authAlg != null) {
@@ -142,22 +159,33 @@ public class IpsecSadEntryCustomizer extends FutureJVppCustomizer
integKey =
((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipsec.rev181214.ipsec.sa.ah.grouping.ah.authentication.algorithm.HmacMd596) authAlg)
.getHmacMd596().getKeyStr().stringValue();
- targetEntry.integrityAlgorithm = 1;
+ request.entry.integrityAlgorithm = IpsecIntegAlg.IPSEC_API_INTEG_ALG_MD5_96;
} else if (authAlg instanceof org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipsec.rev181214.ipsec.sa.ah.grouping.ah.authentication.algorithm.HmacSha196) {
integKey =
((org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipsec.rev181214.ipsec.sa.ah.grouping.ah.authentication.algorithm.HmacSha196) authAlg)
.getHmacSha196().getKeyStr().stringValue();
- targetEntry.integrityAlgorithm = 2;
+ request.entry.integrityAlgorithm = IpsecIntegAlg.IPSEC_API_INTEG_ALG_SHA1_96;
} else {
- targetEntry.integrityAlgorithm = 0;
+ request.entry.integrityAlgorithm = IpsecIntegAlg.IPSEC_API_INTEG_ALG_NONE;
return;
}
- targetEntry.integrityKey = integKey.getBytes();
- targetEntry.integrityKeyLength = (byte) integKey.getBytes().length;
+ request.entry.integrityKey = new Key();
+ request.entry.integrityKey.data = integKey.getBytes();
+ request.entry.integrityKey.length = (byte) integKey.getBytes().length;
+ request.entry.cryptoKey = new Key();
+ request.entry.cryptoKey.data = null;
+ request.entry.cryptoKey.length = 0 ;
}
}
- private void fillEspAuthentication(IpsecSadAddDelEntry targetEntry, Esp data) {
+ private void fillAhEncryption(IpsecSadEntryAddDel request, Ah data) {
+ request.entry.cryptoAlgorithm = IpsecCryptoAlg.IPSEC_API_CRYPTO_ALG_NONE;
+ request.entry.cryptoKey = new Key();
+ request.entry.cryptoKey.data = null;
+ request.entry.cryptoKey.length = 0;
+ }
+
+ private void fillEspAuthentication(IpsecSadEntryAddDel request, Esp data) {
//0 = None, 1 = MD5-96, 2 = SHA1-96, 3 = SHA-256, 4 = SHA-384, 5=SHA-512
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipsec.rev181214.ipsec.sa.esp.grouping.esp.Authentication
authAlg = data.getAuthentication();
@@ -165,57 +193,58 @@ public class IpsecSadEntryCustomizer extends FutureJVppCustomizer
String integKey;
if (authAlg.getAuthenticationAlgorithm() instanceof HmacMd596) {
integKey = ((HmacMd596) authAlg.getAuthenticationAlgorithm()).getHmacMd596().getKeyStr().stringValue();
- targetEntry.integrityAlgorithm = 1;
+ request.entry.integrityAlgorithm = IpsecIntegAlg.IPSEC_API_INTEG_ALG_MD5_96;
} else if (authAlg.getAuthenticationAlgorithm() instanceof HmacSha196) {
integKey =
((HmacSha196) authAlg.getAuthenticationAlgorithm()).getHmacSha196().getKeyStr().stringValue();
- targetEntry.integrityAlgorithm = 2;
+ request.entry.integrityAlgorithm = IpsecIntegAlg.IPSEC_API_INTEG_ALG_SHA1_96;
} else {
- targetEntry.integrityAlgorithm = 0;
+ request.entry.integrityAlgorithm = IpsecIntegAlg.IPSEC_API_INTEG_ALG_NONE;
return;
}
- targetEntry.integrityKey = integKey.getBytes();
- targetEntry.integrityKeyLength = (byte) integKey.getBytes().length;
+ request.entry.integrityKey = new Key();
+ request.entry.integrityKey.data = integKey.getBytes();
+ request.entry.integrityKey.length = (byte) integKey.getBytes().length;
}
}
- private void fillEspEncryption(IpsecSadAddDelEntry targetEntry, Esp data) {
+ private void fillEspEncryption(IpsecSadEntryAddDel request, Esp data) {
//0 = Null, 1 = AES-CBC-128, 2 = AES-CBC-192, 3 = AES-CBC-256, 4 = 3DES-CBC
if (data.getEncryption() != null && data.getEncryption().getEncryptionAlgorithm() != null) {
String cryptoKey = "";
EncryptionAlgorithm encrAlg = data.getEncryption().getEncryptionAlgorithm();
if (encrAlg instanceof Aes128Cbc) {
cryptoKey = ((Aes128Cbc) encrAlg).getAes128Cbc().getKeyStr().stringValue();
- targetEntry.cryptoAlgorithm = 1;
+ request.entry.cryptoAlgorithm = IpsecCryptoAlg.IPSEC_API_CRYPTO_ALG_AES_CBC_128;
} else if (encrAlg instanceof Aes192Cbc) {
cryptoKey = ((Aes192Cbc) encrAlg).getAes192Cbc().getKeyStr().stringValue();
- targetEntry.cryptoAlgorithm = 2;
+ request.entry.cryptoAlgorithm = IpsecCryptoAlg.IPSEC_API_CRYPTO_ALG_AES_CBC_192;
} else if (encrAlg instanceof Aes256Cbc) {
cryptoKey = ((Aes256Cbc) encrAlg).getAes256Cbc().getKeyStr().stringValue();
- targetEntry.cryptoAlgorithm = 3;
+ request.entry.cryptoAlgorithm = IpsecCryptoAlg.IPSEC_API_CRYPTO_ALG_AES_CBC_256;
} else if (encrAlg instanceof DesCbc) {
cryptoKey = ((DesCbc) encrAlg).getDesCbc().getKeyStr().stringValue();
- targetEntry.cryptoAlgorithm = 4;
+ // TODO verify before the value was "4" now the result is "10"
+ request.entry.cryptoAlgorithm = IpsecCryptoAlg.IPSEC_API_CRYPTO_ALG_DES_CBC;
} else {
- targetEntry.cryptoAlgorithm = 0;
+ request.entry.cryptoAlgorithm = IpsecCryptoAlg.IPSEC_API_CRYPTO_ALG_NONE;
return;
}
- targetEntry.cryptoKey = cryptoKey.getBytes();
- targetEntry.cryptoKeyLength = (byte) cryptoKey.getBytes().length;
+ request.entry.cryptoKey = new Key();
+ request.entry.cryptoKey.data = cryptoKey.getBytes();
+ request.entry.cryptoKey.length = (byte) cryptoKey.getBytes().length;
}
}
- private void fillAddresses(IpsecSadAddDelEntry targetEntry, SadEntries data) {
+ private void fillAddresses(IpsecSadEntryAddDel request, SadEntries data) {
if (data.getSourceAddress() != null && data.getSourceAddress().getIpAddress() != null) {
IpAddress sourceAddr = data.getSourceAddress().getIpAddress();
if (sourceAddr instanceof Ipv4Address) {
Ipv4Address ipv4 = (Ipv4Address) sourceAddr;
- targetEntry.isTunnelIpv6 = 0;
- targetEntry.tunnelSrcAddress = ipv4AddressNoZoneToArray(ipv4.getIpv4Address().getValue());
+ request.entry.tunnelSrc = ipv4AddressToAddress(ipv4.getIpv4Address());
} else if (sourceAddr instanceof Ipv6Address) {
Ipv6Address ipv6 = (Ipv6Address) sourceAddr;
- targetEntry.isTunnelIpv6 = 1;
- targetEntry.tunnelSrcAddress = ipv6AddressNoZoneToArray(ipv6.getIpv6Address());
+ request.entry.tunnelSrc = ipv6AddressToAddress(ipv6.getIpv6Address());
}
}
@@ -224,12 +253,10 @@ public class IpsecSadEntryCustomizer extends FutureJVppCustomizer
if (destAddr instanceof Ipv4Address) {
Ipv4Address ipv4 = (Ipv4Address) destAddr;
- targetEntry.isTunnelIpv6 = 0;
- targetEntry.tunnelDstAddress = ipv4AddressNoZoneToArray(ipv4.getIpv4Address().getValue());
+ request.entry.tunnelDst = ipv4AddressToAddress(ipv4.getIpv4Address());
} else if (destAddr instanceof Ipv6Address) {
Ipv6Address ipv6 = (Ipv6Address) destAddr;
- targetEntry.isTunnelIpv6 = 1;
- targetEntry.tunnelDstAddress = ipv6AddressNoZoneToArray(ipv6.getIpv6Address());
+ request.entry.tunnelDst = ipv6AddressToAddress(ipv6.getIpv6Address());
}
}
}
diff --git a/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/IpsecSpdCustomizer.java b/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/IpsecSpdCustomizer.java
index 771cf676a..870eeb776 100644
--- a/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/IpsecSpdCustomizer.java
+++ b/ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/IpsecSpdCustomizer.java
@@ -25,8 +25,10 @@ import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.IpsecSpdAddDel;
-import io.fd.vpp.jvpp.core.dto.IpsecSpdAddDelEntry;
+import io.fd.vpp.jvpp.core.dto.IpsecSpdEntryAddDel;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import io.fd.vpp.jvpp.core.types.IpsecSpdAction;
+import io.fd.vpp.jvpp.core.types.IpsecSpdEntry;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.ipsec.rev181213.IpsecSpdEntriesAugmentation;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipsec.rev181214.ipsec.Spd;
@@ -78,71 +80,65 @@ public class IpsecSpdCustomizer extends FutureJVppCustomizer
private void addSpdEntry(final InstanceIdentifier<Spd> id, int spdId, final SpdEntries entry)
throws WriteFailedException {
- IpsecSpdAddDelEntry request = new IpsecSpdAddDelEntry();
- request.spdId = spdId;
+ IpsecSpdEntryAddDel request = new IpsecSpdEntryAddDel();
+ request.entry = new IpsecSpdEntry();
+ request.entry.spdId = spdId;
request.isAdd = ByteDataTranslator.BYTE_TRUE;
IpsecSpdEntriesAugmentation entryAug = entry.augmentation(IpsecSpdEntriesAugmentation.class);
if (entryAug == null) {
return;
}
- if (entryAug.isIsIpv6() != null) {
- request.isIpv6 = (byte) (entryAug.isIsIpv6()
- ? 1
- : 0);
- }
if (entryAug.getDirection() != null) {
- request.isOutbound = (byte) entryAug.getDirection().getIntValue();
+ request.entry.isOutbound = (byte) entryAug.getDirection().getIntValue();
}
if (entryAug.getPriority() != null) {
- request.priority = entryAug.getPriority();
+ request.entry.priority = entryAug.getPriority();
}
if (entryAug.getOperation() != null) {
final String operation = entryAug.getOperation().getName();
if (operation.equalsIgnoreCase("bypass")) {
- request.policy = (byte) 0;
+ request.entry.policy = IpsecSpdAction.IPSEC_API_SPD_ACTION_BYPASS;
} else if (operation.equalsIgnoreCase("discard")) {
- request.policy = (byte) 1;
+ request.entry.policy = IpsecSpdAction.IPSEC_API_SPD_ACTION_DISCARD;
} else if (operation.equalsIgnoreCase("protect")) {
- request.policy = (byte) 3;
+ request.entry.policy = IpsecSpdAction.IPSEC_API_SPD_ACTION_PROTECT;
}
}
if (entryAug.getLaddrStart() != null) {
if (entryAug.getLaddrStart().getIpv4Address() != null) {
- request.localAddressStart =
- ipv4AddressNoZoneToArray(entryAug.getLaddrStart().getIpv4Address().getValue());
+ request.entry.localAddressStart = ipv4AddressToAddress(entryAug.getLaddrStart().getIpv4Address());
} else if (entryAug.getLaddrStart().getIpv6Address() != null) {
- request.localAddressStart = ipv6AddressNoZoneToArray(entryAug.getLaddrStart().getIpv6Address());
+ request.entry.localAddressStart = ipv6AddressToAddress(entryAug.getLaddrStart().getIpv6Address());
}
}
if (entryAug.getLaddrStop() != null) {
if (entryAug.getLaddrStop().getIpv4Address() != null) {
- request.localAddressStop =
- ipv4AddressNoZoneToArray(entryAug.getLaddrStop().getIpv4Address().getValue());
+ request.entry.localAddressStop = ipv4AddressToAddress(entryAug.getLaddrStop().getIpv4Address());
} else if (entryAug.getLaddrStop().getIpv6Address() != null) {
- request.localAddressStop = ipv6AddressNoZoneToArray(entryAug.getLaddrStop().getIpv6Address());
+ request.entry.localAddressStop = ipv6AddressToAddress(entryAug.getLaddrStop().getIpv6Address());
}
}
if (entryAug.getRaddrStop() != null) {
if (entryAug.getRaddrStop().getIpv4Address() != null) {
- request.remoteAddressStop =
- ipv4AddressNoZoneToArray(entryAug.getRaddrStop().getIpv4Address().getValue());
+ request.entry.remoteAddressStop = ipv4AddressToAddress(entryAug.getRaddrStop().getIpv4Address());
} else if (entryAug.getRaddrStop().getIpv6Address() != null) {
- request.remoteAddressStop = ipv6AddressNoZoneToArray(entryAug.getRaddrStop().getIpv6Address());
+ request.entry.remoteAddressStop = ipv6AddressToAddress(entryAug.getRaddrStop().getIpv6Address());
}
}
if (entryAug.getRaddrStart() != null) {
if (entryAug.getRaddrStart().getIpv4Address() != null) {
- request.remoteAddressStart =
- ipv4AddressNoZoneToArray(entryAug.getRaddrStart().getIpv4Address().getValue());
+ request.entry.remoteAddressStart = ipv4AddressToAddress(entryAug.getRaddrStart().getIpv4Address());
} else if (entryAug.getRaddrStart().getIpv6Address() != null) {
- request.remoteAddressStart = ipv6AddressNoZoneToArray(entryAug.getRaddrStart().getIpv6Address());
+ request.entry.remoteAddressStart = ipv6AddressToAddress(entryAug.getRaddrStart().getIpv6Address());
}
}
- getReplyForWrite(getFutureJVpp().ipsecSpdAddDelEntry(request).toCompletableFuture(), id);
+
+ //TODO HC2VPP-403: missing local and remote port definitions
+ getReplyForWrite(getFutureJVpp().ipsecSpdEntryAddDel(request).toCompletableFuture(), id);
}
}
diff --git a/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/read/IpsecStateSpdCustomizerTest.java b/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/read/IpsecStateSpdCustomizerTest.java
index bf08fa8c3..8c2ad09f9 100644
--- a/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/read/IpsecStateSpdCustomizerTest.java
+++ b/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/read/IpsecStateSpdCustomizerTest.java
@@ -30,6 +30,8 @@ import io.fd.vpp.jvpp.core.dto.IpsecSpdDetails;
import io.fd.vpp.jvpp.core.dto.IpsecSpdDetailsReplyDump;
import io.fd.vpp.jvpp.core.dto.IpsecSpdsDetails;
import io.fd.vpp.jvpp.core.dto.IpsecSpdsDetailsReplyDump;
+import io.fd.vpp.jvpp.core.types.IpsecSpdAction;
+import io.fd.vpp.jvpp.core.types.IpsecSpdEntry;
import java.util.LinkedList;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.ipsec.rev181213.IpsecStateSpdAugmentation;
@@ -38,6 +40,7 @@ import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.ipsec.rev181213.i
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.ipsec.rev181213.ipsec.state.SpdBuilder;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.ipsec.rev181213.ipsec.state.SpdKey;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.ipsec.rev181213.ipsec.state.spd.SpdEntries;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipsec.rev181214.IpsecState;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -47,11 +50,10 @@ public class IpsecStateSpdCustomizerTest extends ReaderCustomizerTest<Spd, SpdBu
private static InstanceIdentifier<Spd> SPD_IID = InstanceIdentifier.create(IpsecState.class)
.augmentation(IpsecStateSpdAugmentation.class).child(Spd.class, new SpdKey(10));
- private static final String LOCAL_ADDR_START = "192.168.11.1";
- private static final String LOCAL_ADDR_END = "192.168.11.255";
+ private static final Ipv4Address LOCAL_ADDR_START = new Ipv4Address("192.168.11.1");
+ private static final Ipv4Address LOCAL_ADDR_END = new Ipv4Address("192.168.11.255");
private static final short PORT_START = 0;
private static final short PORT_END = Short.MAX_VALUE;
- private static final int POLICY_PROTECT = 3;
private static final int SPD_ID = 10;
private static final int SA_ID = 10;
private static final int PROTOCOL = 1;
@@ -71,17 +73,17 @@ public class IpsecStateSpdCustomizerTest extends ReaderCustomizerTest<Spd, SpdBu
final IpsecSpdDetailsReplyDump spdDetailsReply = new IpsecSpdDetailsReplyDump();
LinkedList<IpsecSpdDetails> spdDetails = new LinkedList<>();
IpsecSpdDetails spdDetail = new IpsecSpdDetails();
- spdDetail.isIpv6 = BYTE_FALSE;
- spdDetail.isOutbound = BYTE_TRUE;
- spdDetail.spdId = SPD_ID;
- spdDetail.protocol = PROTOCOL;
- spdDetail.localStartAddr = ipv4AddressNoZoneToArray(LOCAL_ADDR_START);
- spdDetail.localStopAddr = ipv4AddressNoZoneToArray(LOCAL_ADDR_END);
- spdDetail.localStartPort = PORT_START;
- spdDetail.localStopPort = PORT_END;
- spdDetail.policy = POLICY_PROTECT;
- spdDetail.saId = SA_ID;
- spdDetail.priority = PRIORITY;
+ spdDetail.entry = new IpsecSpdEntry();
+ spdDetail.entry.isOutbound = BYTE_TRUE;
+ spdDetail.entry.spdId = SPD_ID;
+ spdDetail.entry.protocol = PROTOCOL;
+ spdDetail.entry.localAddressStart = ipv4AddressToAddress(LOCAL_ADDR_START);
+ spdDetail.entry.localAddressStop = ipv4AddressToAddress(LOCAL_ADDR_END);
+ spdDetail.entry.localPortStart = PORT_START;
+ spdDetail.entry.localPortStop = PORT_END;
+ spdDetail.entry.policy = IpsecSpdAction.IPSEC_API_SPD_ACTION_PROTECT;
+ spdDetail.entry.saId = SA_ID;
+ spdDetail.entry.priority = PRIORITY;
spdDetails.add(spdDetail);
spdDetailsReply.ipsecSpdDetails = spdDetails;
when(api.ipsecSpdDump(any())).thenReturn(future(spdDetailsReply));
diff --git a/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/IpsecSadEntryCustomizerTest.java b/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/IpsecSadEntryCustomizerTest.java
index e477467db..81588fea7 100644
--- a/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/IpsecSadEntryCustomizerTest.java
+++ b/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/IpsecSadEntryCustomizerTest.java
@@ -16,6 +16,8 @@
package io.fd.hc2vpp.ipsec.write;
+import static io.fd.vpp.jvpp.core.types.IpsecSadFlags.IPSEC_API_SAD_FLAG_NONE;
+import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -29,11 +31,19 @@ import io.fd.hc2vpp.ipsec.helpers.SchemaContextTestHelper;
import io.fd.honeycomb.test.tools.HoneycombTestRunner;
import io.fd.honeycomb.test.tools.annotations.InjectTestData;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import io.fd.vpp.jvpp.core.dto.IpsecSadAddDelEntry;
-import io.fd.vpp.jvpp.core.dto.IpsecSadAddDelEntryReply;
+import io.fd.vpp.jvpp.core.dto.IpsecSadEntryAddDel;
+import io.fd.vpp.jvpp.core.dto.IpsecSadEntryAddDelReply;
+import io.fd.vpp.jvpp.core.types.IpsecCryptoAlg;
+import io.fd.vpp.jvpp.core.types.IpsecIntegAlg;
+import io.fd.vpp.jvpp.core.types.IpsecProto;
+import io.fd.vpp.jvpp.core.types.IpsecSadEntry;
+import io.fd.vpp.jvpp.core.types.IpsecSadFlags;
+import io.fd.vpp.jvpp.core.types.IpsecSpdEntry;
+import io.fd.vpp.jvpp.core.types.Key;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipsec.rev181214.IkeEncryptionAlgorithmT;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipsec.rev181214.IkeIntegrityAlgorithmT;
@@ -68,8 +78,8 @@ public class IpsecSadEntryCustomizerTest extends WriterCustomizerTest implements
InstanceIdentifier.create(Ipsec.class).child(Sad.class);
private static final String INTEG_KEY = "0123456789012346";
private static final String CRYPTO_KEY = "9876543210987654";
- private static final String TNL_SRC_ADDR = "192.168.1.1";
- private static final String TNL_DST_ADDR = "192.168.1.2";
+ private static final Ipv4Address TNL_SRC_ADDR = new Ipv4Address("192.168.1.1");
+ private static final Ipv4Address TNL_DST_ADDR = new Ipv4Address("192.168.1.2");
private static final int SPI_1002 = 1002;
private static final int SAD_ID = 10;
@@ -80,29 +90,30 @@ public class IpsecSadEntryCustomizerTest extends WriterCustomizerTest implements
@Override
protected void setUpTest() throws Exception {
customizer = new IpsecSadEntryCustomizer(api, namingCntext);
- when(api.ipsecSadAddDelEntry(any())).thenReturn(future(new IpsecSadAddDelEntryReply()));
+ when(api.ipsecSadEntryAddDel(any())).thenReturn(future(new IpsecSadEntryAddDelReply()));
}
@Test
public void testWrite(@InjectTestData(resourcePath = "/sadEntries/addDelSadEntry.json", id = SAD_PATH) Sad sad)
throws WriteFailedException {
final SadEntries data = sad.getSadEntries().get(0);
- final IpsecSadAddDelEntry request = new IpsecSadAddDelEntry();
+ final IpsecSadEntryAddDel request = new IpsecSadEntryAddDel();
request.isAdd = BYTE_TRUE;
- request.spi = SPI_1002;
- request.sadId = SAD_ID;
- request.isTunnel = BYTE_TRUE;
- request.isTunnelIpv6 = BYTE_FALSE;
- request.integrityKey = INTEG_KEY.getBytes();
- request.integrityKeyLength = (byte) request.integrityKey.length;
- request.cryptoKey = CRYPTO_KEY.getBytes();
- request.cryptoKeyLength = (byte) request.cryptoKey.length;
- request.useAntiReplay = 0;
- request.tunnelSrcAddress = ipv4AddressNoZoneToArray(TNL_SRC_ADDR);
- request.tunnelDstAddress = ipv4AddressNoZoneToArray(TNL_DST_ADDR);
+ request.entry = new io.fd.vpp.jvpp.core.types.IpsecSadEntry();
+ request.entry.spi = SPI_1002;
+ request.entry.sadId = SAD_ID;
+ request.entry.integrityKey = new Key();
+ request.entry.integrityKey.data = INTEG_KEY.getBytes();
+ request.entry.integrityKey.length = (byte) INTEG_KEY.getBytes().length;
+ request.entry.cryptoKey = new Key();
+ request.entry.cryptoKey.data = CRYPTO_KEY.getBytes();
+ request.entry.cryptoKey.length = (byte) CRYPTO_KEY.getBytes().length;
+ request.entry.flags = IpsecSadFlags.IPSEC_API_SAD_FLAG_IS_TUNNEL;
+ request.entry.tunnelSrc = ipv4AddressToAddress(TNL_SRC_ADDR);
+ request.entry.tunnelDst = ipv4AddressToAddress(TNL_DST_ADDR);
// ESP
- request.protocol = BYTE_TRUE; //0 = AH, 1 = ESP
+ request.entry.protocol = IpsecProto.IPSEC_API_PROTO_ESP;
// - auth MD5-96
// - crypto Aes-Cbc-128
testEspAuthEncrCombination(data, IkeIntegrityAlgorithmT.AuthHmacMd596,
@@ -132,10 +143,11 @@ public class IpsecSadEntryCustomizerTest extends WriterCustomizerTest implements
IkeEncryptionAlgorithmT.EncrDes, request);
// AH
- request.protocol = BYTE_FALSE;
- request.cryptoAlgorithm = 0;
- request.cryptoKey = null;
- request.cryptoKeyLength = 0;
+ request.entry.protocol = IpsecProto.IPSEC_API_PROTO_AH;
+ request.entry.cryptoAlgorithm = IpsecCryptoAlg.IPSEC_API_CRYPTO_ALG_NONE;
+ request.entry.cryptoKey = new Key();
+ request.entry.cryptoKey.data = null;
+ request.entry.cryptoKey.length = 0;
// - auth SHA1-96
testAhAuthorization(data, IkeIntegrityAlgorithmT.AuthHmacSha196, request);
// - auth MD5-96
@@ -151,20 +163,24 @@ public class IpsecSadEntryCustomizerTest extends WriterCustomizerTest implements
final SadEntries after = relayAfter.getSadEntries().get(0);
final Long spi = after.getSpi();
customizer.updateCurrentAttributes(getId(IpsecTrafficDirection.Outbound, spi), before, after, writeContext);
- final IpsecSadAddDelEntry request = new IpsecSadAddDelEntry();
+ final IpsecSadEntryAddDel request = new IpsecSadEntryAddDel();
request.isAdd = BYTE_TRUE;
- request.spi = SPI_1002;
- request.sadId = SAD_ID;
- request.protocol = BYTE_FALSE;
- request.isTunnel = BYTE_FALSE;
- request.isTunnelIpv6 = BYTE_TRUE;
- request.integrityAlgorithm = 1;
- request.integrityKey = INTEG_KEY.getBytes();
- request.integrityKeyLength = (byte) request.integrityKey.length;
- request.useAntiReplay = BYTE_TRUE;
- request.tunnelSrcAddress = ipv6AddressNoZoneToArray(Ipv6Address.getDefaultInstance("2001::11"));
- request.tunnelDstAddress = ipv6AddressNoZoneToArray(Ipv6Address.getDefaultInstance("2001::12"));
- verify(api).ipsecSadAddDelEntry(request);
+ request.entry = new IpsecSadEntry();
+ request.entry.spi = SPI_1002;
+ request.entry.sadId = SAD_ID;
+ request.entry.protocol = IpsecProto.IPSEC_API_PROTO_AH;
+ request.entry.integrityAlgorithm = IpsecIntegAlg.IPSEC_API_INTEG_ALG_MD5_96;
+ request.entry.integrityKey = new Key();
+ request.entry.integrityKey.data = INTEG_KEY.getBytes();
+ request.entry.integrityKey.length = (byte) INTEG_KEY.getBytes().length;
+ request.entry.cryptoAlgorithm = IpsecCryptoAlg.IPSEC_API_CRYPTO_ALG_NONE;
+ request.entry.cryptoKey = new Key();
+ request.entry.cryptoKey.data = null;
+ request.entry.cryptoKey.length = 0;
+ request.entry.flags = IpsecSadFlags.IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY;
+ request.entry.tunnelSrc = ipv6AddressToAddress(Ipv6Address.getDefaultInstance("2001::11"));
+ request.entry.tunnelDst = ipv6AddressToAddress(Ipv6Address.getDefaultInstance("2001::12"));
+ verify(api).ipsecSadEntryAddDel(request);
}
@Test
@@ -173,11 +189,13 @@ public class IpsecSadEntryCustomizerTest extends WriterCustomizerTest implements
final SadEntries data = sad.getSadEntries().get(0);
final Long spi = data.getSpi();
customizer.deleteCurrentAttributes(getId(IpsecTrafficDirection.Outbound, spi), data, writeContext);
- final IpsecSadAddDelEntry request = new IpsecSadAddDelEntry();
+ final IpsecSadEntryAddDel request = new IpsecSadEntryAddDel();
request.isAdd = BYTE_FALSE;
- request.spi = SPI_1002;
- request.sadId = SAD_ID;
- verify(api).ipsecSadAddDelEntry(request);
+ request.entry = new IpsecSadEntry();
+ request.entry.spi = SPI_1002;
+ request.entry.sadId = SAD_ID;
+ request.entry.flags = IPSEC_API_SAD_FLAG_NONE;
+ verify(api).ipsecSadEntryAddDel(request);
}
private InstanceIdentifier<SadEntries> getId(final IpsecTrafficDirection direction, final Long spi) {
@@ -185,7 +203,7 @@ public class IpsecSadEntryCustomizerTest extends WriterCustomizerTest implements
}
private void testAhAuthorization(final SadEntries otherData, final IkeIntegrityAlgorithmT authAlg,
- final IpsecSadAddDelEntry request) throws WriteFailedException {
+ final IpsecSadEntryAddDel request) throws WriteFailedException {
SadEntriesBuilder builder = new SadEntriesBuilder(otherData);
builder.setEsp(null);
AhBuilder ahBuilder = new AhBuilder();
@@ -193,11 +211,11 @@ public class IpsecSadEntryCustomizerTest extends WriterCustomizerTest implements
builder.setAh(ahBuilder.build());
customizer.writeCurrentAttributes(getId(IpsecTrafficDirection.Outbound, Integer.toUnsignedLong(SPI_1002)),
builder.build(), writeContext);
- verify(api).ipsecSadAddDelEntry(request);
+ verify(api).ipsecSadEntryAddDel(request);
}
private void testEspAuthEncrCombination(final SadEntries otherData, final IkeIntegrityAlgorithmT authAlg,
- final IkeEncryptionAlgorithmT encrAlg, final IpsecSadAddDelEntry request)
+ final IkeEncryptionAlgorithmT encrAlg, final IpsecSadEntryAddDel request)
throws WriteFailedException {
SadEntriesBuilder builder = new SadEntriesBuilder(otherData);
builder.setAh(null);
@@ -209,26 +227,26 @@ public class IpsecSadEntryCustomizerTest extends WriterCustomizerTest implements
builder.build(), writeContext);
if (encrAlg == IkeEncryptionAlgorithmT.EncrAesCbc128) {
- request.cryptoAlgorithm = 1;
+ request.entry.cryptoAlgorithm = IpsecCryptoAlg.IPSEC_API_CRYPTO_ALG_AES_CBC_128;
} else if (encrAlg == IkeEncryptionAlgorithmT.EncrAesCbc192) {
- request.cryptoAlgorithm = 2;
+ request.entry.cryptoAlgorithm = IpsecCryptoAlg.IPSEC_API_CRYPTO_ALG_AES_CBC_192;
} else if (encrAlg == IkeEncryptionAlgorithmT.EncrAesCbc256) {
- request.cryptoAlgorithm = 3;
+ request.entry.cryptoAlgorithm = IpsecCryptoAlg.IPSEC_API_CRYPTO_ALG_AES_CBC_256;
} else if (encrAlg == IkeEncryptionAlgorithmT.EncrDes) {
- request.cryptoAlgorithm = 4;
+ request.entry.cryptoAlgorithm = IpsecCryptoAlg.IPSEC_API_CRYPTO_ALG_DES_CBC;
} else {
- request.cryptoAlgorithm = 0;
+ request.entry.cryptoAlgorithm = IpsecCryptoAlg.IPSEC_API_CRYPTO_ALG_NONE;
}
if (authAlg == IkeIntegrityAlgorithmT.AuthHmacMd596) {
- request.integrityAlgorithm = 1;
+ request.entry.integrityAlgorithm = IpsecIntegAlg.IPSEC_API_INTEG_ALG_MD5_96;
} else if (authAlg == IkeIntegrityAlgorithmT.AuthHmacSha196) {
- request.integrityAlgorithm = 2;
+ request.entry.integrityAlgorithm = IpsecIntegAlg.IPSEC_API_INTEG_ALG_SHA1_96;
} else {
- request.integrityAlgorithm = 0;
+ request.entry.integrityAlgorithm = IpsecIntegAlg.IPSEC_API_INTEG_ALG_NONE;
}
- verify(api).ipsecSadAddDelEntry(request);
+ verify(api).ipsecSadEntryAddDel(request);
}
private Encryption getEspEncryption(IkeEncryptionAlgorithmT alg) {
diff --git a/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/IpsecSpdCustomizerTest.java b/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/IpsecSpdCustomizerTest.java
index a4b294002..da9b7425b 100644
--- a/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/IpsecSpdCustomizerTest.java
+++ b/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/IpsecSpdCustomizerTest.java
@@ -29,9 +29,11 @@ import io.fd.honeycomb.test.tools.HoneycombTestRunner;
import io.fd.honeycomb.test.tools.annotations.InjectTestData;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.IpsecSpdAddDel;
-import io.fd.vpp.jvpp.core.dto.IpsecSpdAddDelEntry;
-import io.fd.vpp.jvpp.core.dto.IpsecSpdAddDelEntryReply;
import io.fd.vpp.jvpp.core.dto.IpsecSpdAddDelReply;
+import io.fd.vpp.jvpp.core.dto.IpsecSpdEntryAddDel;
+import io.fd.vpp.jvpp.core.dto.IpsecSpdEntryAddDelReply;
+import io.fd.vpp.jvpp.core.types.IpsecSpdAction;
+import io.fd.vpp.jvpp.core.types.IpsecSpdEntry;
import java.util.Collections;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -56,7 +58,7 @@ public class IpsecSpdCustomizerTest extends WriterCustomizerTest implements Sche
protected void setUpTest() throws Exception {
customizer = new IpsecSpdCustomizer(api);
when(api.ipsecSpdAddDel(any())).thenReturn(future(new IpsecSpdAddDelReply()));
- when(api.ipsecSpdAddDelEntry(any())).thenReturn(future(new IpsecSpdAddDelEntryReply()));
+ when(api.ipsecSpdEntryAddDel(any())).thenReturn(future(new IpsecSpdEntryAddDelReply()));
}
@Test
@@ -69,8 +71,8 @@ public class IpsecSpdCustomizerTest extends WriterCustomizerTest implements Sche
createSpdRequest.spdId = SPD_ID;
verify(api).ipsecSpdAddDel(createSpdRequest);
- verify(api).ipsecSpdAddDelEntry(translateSpdEntry(spd.getSpdEntries().get(0), SPD_ID, true));
- verify(api).ipsecSpdAddDelEntry(translateSpdEntry(spd.getSpdEntries().get(1), SPD_ID, true));
+ verify(api).ipsecSpdEntryAddDel(translateSpdEntry(spd.getSpdEntries().get(0), SPD_ID, true));
+ verify(api).ipsecSpdEntryAddDel(translateSpdEntry(spd.getSpdEntries().get(1), SPD_ID, true));
}
@Test
@@ -81,7 +83,7 @@ public class IpsecSpdCustomizerTest extends WriterCustomizerTest implements Sche
Spd before = ipsecBefore.getSpd().get(0);
Spd after = ipsecAfter.getSpd().get(0);
customizer.updateCurrentAttributes(getSpdId(SPD_ID), before, after, writeContext);
- verify(api).ipsecSpdAddDelEntry(translateSpdEntry(after.getSpdEntries().get(0), SPD_ID, true));
+ verify(api).ipsecSpdEntryAddDel(translateSpdEntry(after.getSpdEntries().get(0), SPD_ID, true));
}
@Test
@@ -102,71 +104,64 @@ public class IpsecSpdCustomizerTest extends WriterCustomizerTest implements Sche
return InstanceIdentifier.create(Ipsec.class).child(Spd.class, new SpdKey(spdId));
}
- private IpsecSpdAddDelEntry translateSpdEntry(final SpdEntries entry, int spdId, boolean isAdd) {
- IpsecSpdAddDelEntry request = new IpsecSpdAddDelEntry();
- request.spdId = spdId;
+ private IpsecSpdEntryAddDel translateSpdEntry(final SpdEntries entry, int spdId, boolean isAdd) {
+ IpsecSpdEntryAddDel request = new IpsecSpdEntryAddDel();
+ request.entry = new IpsecSpdEntry();
+ request.entry.spdId = spdId;
request.isAdd = isAdd
? BYTE_TRUE
: BYTE_FALSE;
IpsecSpdEntriesAugmentation aug = entry.augmentation(IpsecSpdEntriesAugmentation.class);
if (aug != null) {
- if (aug.isIsIpv6() != null) {
- request.isIpv6 = (byte) (aug.isIsIpv6()
- ? 1
- : 0);
- }
if (aug.getDirection() != null) {
- request.isOutbound = (byte) aug.getDirection().getIntValue();
+ request.entry.isOutbound = (byte) aug.getDirection().getIntValue();
}
if (aug.getPriority() != null) {
- request.priority = aug.getPriority();
+ request.entry.priority = aug.getPriority();
}
if (aug.getOperation() != null) {
final String operation = aug.getOperation().getName();
if (operation.equalsIgnoreCase("bypass")) {
- request.policy = (byte) 0;
+ request.entry.policy = IpsecSpdAction.IPSEC_API_SPD_ACTION_BYPASS;
} else if (operation.equalsIgnoreCase("discard")) {
- request.policy = (byte) 1;
+ request.entry.policy = IpsecSpdAction.IPSEC_API_SPD_ACTION_DISCARD;
} else if (operation.equalsIgnoreCase("protect")) {
- request.policy = (byte) 3;
+ request.entry.policy = IpsecSpdAction.IPSEC_API_SPD_ACTION_PROTECT;
}
}
if (aug.getLaddrStart() != null) {
if (aug.getLaddrStart().getIpv4Address() != null) {
- request.localAddressStart =
- ipv4AddressNoZoneToArray(aug.getLaddrStart().getIpv4Address().getValue());
+ request.entry.localAddressStart = ipv4AddressToAddress(aug.getLaddrStart().getIpv4Address());
} else if (aug.getLaddrStart().getIpv6Address() != null) {
- request.localAddressStart = ipv6AddressNoZoneToArray(aug.getLaddrStart().getIpv6Address());
+ request.entry.localAddressStart = ipv6AddressToAddress(aug.getLaddrStart().getIpv6Address());
}
}
if (aug.getLaddrStop() != null) {
if (aug.getLaddrStop().getIpv4Address() != null) {
- request.localAddressStop = ipv4AddressNoZoneToArray(aug.getLaddrStop().getIpv4Address().getValue());
+ request.entry.localAddressStop = ipv4AddressToAddress(aug.getLaddrStop().getIpv4Address());
} else if (aug.getLaddrStop().getIpv6Address() != null) {
- request.localAddressStop = ipv6AddressNoZoneToArray(aug.getLaddrStop().getIpv6Address());
+ request.entry.localAddressStop = ipv6AddressToAddress(aug.getLaddrStop().getIpv6Address());
}
}
if (aug.getRaddrStop() != null) {
if (aug.getRaddrStop().getIpv4Address() != null) {
- request.remoteAddressStop =
- ipv4AddressNoZoneToArray(aug.getRaddrStop().getIpv4Address().getValue());
+ request.entry.remoteAddressStop = ipv4AddressToAddress(aug.getRaddrStop().getIpv4Address());
} else if (aug.getRaddrStop().getIpv6Address() != null) {
- request.remoteAddressStop = ipv6AddressNoZoneToArray(aug.getRaddrStop().getIpv6Address());
+ request.entry.remoteAddressStop = ipv6AddressToAddress(aug.getRaddrStop().getIpv6Address());
}
}
if (aug.getRaddrStart() != null) {
if (aug.getRaddrStart().getIpv4Address() != null) {
- request.remoteAddressStart =
- ipv4AddressNoZoneToArray(aug.getRaddrStart().getIpv4Address().getValue());
+ request.entry.remoteAddressStart = ipv4AddressToAddress(aug.getRaddrStart().getIpv4Address());
} else if (aug.getRaddrStart().getIpv6Address() != null) {
- request.remoteAddressStart = ipv6AddressNoZoneToArray(aug.getRaddrStart().getIpv6Address());
+ request.entry.remoteAddressStart = ipv6AddressToAddress(aug.getRaddrStart().getIpv6Address());
}
}
}
diff --git a/l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv4/Ipv4NeighbourCustomizer.java b/l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv4/Ipv4NeighbourCustomizer.java
index 48a2d5aed..1da148a31 100644
--- a/l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv4/Ipv4NeighbourCustomizer.java
+++ b/l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv4/Ipv4NeighbourCustomizer.java
@@ -30,6 +30,7 @@ import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager.DumpCacheManag
import io.fd.vpp.jvpp.core.dto.IpNeighborDetails;
import io.fd.vpp.jvpp.core.dto.IpNeighborDetailsReplyDump;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import io.fd.vpp.jvpp.core.types.IpNeighborFlags;
import java.util.List;
import java.util.function.Function;
import javax.annotation.Nonnull;
@@ -74,12 +75,14 @@ public class Ipv4NeighbourCustomizer extends IpNeighbourReader
if (dumpOpt.isPresent()) {
dumpOpt.get().ipNeighborDetails
.stream()
- .filter(ipNeighborDetails -> ip.equals(arrayToIpv4AddressNoZone(ipNeighborDetails.ipAddress)))
+ .filter(ipNeighborDetails -> ip.equals(arrayToIpv4AddressNoZone(
+ ipNeighborDetails.neighbor.ipAddress.un.getIp4().ip4Address)))
.findFirst()
- .ifPresent(ipNeighborDetails -> builder.setIp(arrayToIpv4AddressNoZone(ipNeighborDetails.ipAddress))
+ .ifPresent(ipNeighborDetails -> builder.setIp(arrayToIpv4AddressNoZone(
+ ipNeighborDetails.neighbor.ipAddress.un.getIp4().ip4Address))
.withKey(keyMapper().apply(ipNeighborDetails))
- .setLinkLayerAddress(toPhysAddress(ipNeighborDetails.macAddress))
- .setOrigin(ipNeighborDetails.isStatic == 0
+ .setLinkLayerAddress(toPhysAddress(ipNeighborDetails.neighbor.macAddress.macaddress))
+ .setOrigin(ipNeighborDetails.neighbor.flags != IpNeighborFlags.IP_API_NEIGHBOR_FLAG_STATIC
? Dynamic
: Static));
}
@@ -97,6 +100,7 @@ public class Ipv4NeighbourCustomizer extends IpNeighbourReader
}
private Function<IpNeighborDetails, NeighborKey> keyMapper() {
- return ipNeighborDetails -> new NeighborKey(arrayToIpv4AddressNoZone(ipNeighborDetails.ipAddress));
+ return ipNeighborDetails -> new NeighborKey(
+ arrayToIpv4AddressNoZone(ipNeighborDetails.neighbor.ipAddress.un.getIp4().ip4Address));
}
} \ No newline at end of file
diff --git a/l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv4/subinterface/SubInterfaceIpv4NeighbourCustomizer.java b/l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv4/subinterface/SubInterfaceIpv4NeighbourCustomizer.java
index 8e0267aca..c1c2f8559 100644
--- a/l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv4/subinterface/SubInterfaceIpv4NeighbourCustomizer.java
+++ b/l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv4/subinterface/SubInterfaceIpv4NeighbourCustomizer.java
@@ -67,11 +67,13 @@ public class SubInterfaceIpv4NeighbourCustomizer extends IpNeighbourReader
if (dumpOpt.isPresent()) {
dumpOpt.get().ipNeighborDetails
.stream()
- .filter(ipNeighborDetails -> ip.equals(arrayToIpv4AddressNoZone(ipNeighborDetails.ipAddress)))
+ .filter(ipNeighborDetails -> ip.equals(arrayToIpv4AddressNoZone(
+ ipNeighborDetails.neighbor.ipAddress.un.getIp4().ip4Address)))
.findFirst()
- .ifPresent(ipNeighborDetails -> builder.setIp(arrayToIpv4AddressNoZone(ipNeighborDetails.ipAddress))
+ .ifPresent(ipNeighborDetails -> builder.setIp(arrayToIpv4AddressNoZone(
+ ipNeighborDetails.neighbor.ipAddress.un.getIp4().ip4Address))
.withKey(keyMapper().apply(ipNeighborDetails))
- .setLinkLayerAddress(toPhysAddress(ipNeighborDetails.macAddress)));
+ .setLinkLayerAddress(toPhysAddress(ipNeighborDetails.neighbor.macAddress.macaddress)));
}
}
@@ -87,6 +89,7 @@ public class SubInterfaceIpv4NeighbourCustomizer extends IpNeighbourReader
}
private Function<IpNeighborDetails, NeighborKey> keyMapper() {
- return ipNeighborDetails -> new NeighborKey(arrayToIpv4AddressNoZone(ipNeighborDetails.ipAddress));
+ return ipNeighborDetails -> new NeighborKey(
+ arrayToIpv4AddressNoZone(ipNeighborDetails.neighbor.ipAddress.un.getIp4().ip4Address));
}
}
diff --git a/l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv6/Ipv6NeighbourCustomizer.java b/l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv6/Ipv6NeighbourCustomizer.java
index 7d7578777..92f4962ee 100644
--- a/l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv6/Ipv6NeighbourCustomizer.java
+++ b/l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv6/Ipv6NeighbourCustomizer.java
@@ -31,6 +31,7 @@ import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
import io.fd.vpp.jvpp.core.dto.IpNeighborDetails;
import io.fd.vpp.jvpp.core.dto.IpNeighborDetailsReplyDump;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import io.fd.vpp.jvpp.core.types.IpNeighborFlags;
import java.util.List;
import java.util.function.Function;
import javax.annotation.Nonnull;
@@ -69,12 +70,14 @@ public class Ipv6NeighbourCustomizer extends IpNeighbourReader
if (dumpOpt.isPresent()) {
dumpOpt.get().ipNeighborDetails
.stream()
- .filter(ipNeighborDetails -> ip.equals(arrayToIpv6AddressNoZone(ipNeighborDetails.ipAddress)))
+ .filter(ipNeighborDetails -> ip.equals(arrayToIpv6AddressNoZone(
+ ipNeighborDetails.neighbor.ipAddress.un.getIp6().ip6Address)))
.findFirst()
- .ifPresent(ipNeighborDetails -> builder.setIp(arrayToIpv6AddressNoZone(ipNeighborDetails.ipAddress))
+ .ifPresent(ipNeighborDetails -> builder.setIp(arrayToIpv6AddressNoZone(
+ ipNeighborDetails.neighbor.ipAddress.un.getIp6().ip6Address))
.withKey(keyMapper().apply(ipNeighborDetails))
- .setLinkLayerAddress(toPhysAddress(ipNeighborDetails.macAddress))
- .setOrigin(ipNeighborDetails.isStatic == 0
+ .setLinkLayerAddress(toPhysAddress(ipNeighborDetails.neighbor.macAddress.macaddress))
+ .setOrigin(ipNeighborDetails.neighbor.flags != IpNeighborFlags.IP_API_NEIGHBOR_FLAG_STATIC
? Dynamic
: Static));
}
@@ -92,6 +95,7 @@ public class Ipv6NeighbourCustomizer extends IpNeighbourReader
}
private Function<IpNeighborDetails, NeighborKey> keyMapper() {
- return ipNeighborDetails -> new NeighborKey(arrayToIpv6AddressNoZone(ipNeighborDetails.ipAddress));
+ return ipNeighborDetails -> new NeighborKey(
+ arrayToIpv6AddressNoZone(ipNeighborDetails.neighbor.ipAddress.un.getIp6().ip6Address));
}
} \ No newline at end of file
diff --git a/l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv6/nd/NdProxyCustomizer.java b/l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv6/nd/NdProxyCustomizer.java
index acdb2098b..93e6275b9 100644
--- a/l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv6/nd/NdProxyCustomizer.java
+++ b/l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv6/nd/NdProxyCustomizer.java
@@ -88,7 +88,7 @@ public final class NdProxyCustomizer extends FutureJVppCustomizer
return dump.get().ip6NdProxyDetails.stream()
.filter(detail -> detail.swIfIndex == swIfIndex)
- .map(detail -> new NdProxyKey(arrayToIpv6AddressNoZone(detail.address)))
+ .map(detail -> new NdProxyKey(arrayToIpv6AddressNoZone(detail.ip.ip6Address)))
.collect(Collectors.toList());
}
diff --git a/l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv6/subinterface/SubInterfaceIpv6NeighbourCustomizer.java b/l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv6/subinterface/SubInterfaceIpv6NeighbourCustomizer.java
index 4a0286173..1227abc03 100644
--- a/l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv6/subinterface/SubInterfaceIpv6NeighbourCustomizer.java
+++ b/l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv6/subinterface/SubInterfaceIpv6NeighbourCustomizer.java
@@ -67,11 +67,13 @@ public class SubInterfaceIpv6NeighbourCustomizer extends IpNeighbourReader
if (dumpOpt.isPresent()) {
dumpOpt.get().ipNeighborDetails
.stream()
- .filter(ipNeighborDetails -> ip.equals(arrayToIpv6AddressNoZone(ipNeighborDetails.ipAddress)))
+ .filter(ipNeighborDetails -> ip.equals(arrayToIpv6AddressNoZone(
+ ipNeighborDetails.neighbor.ipAddress.un.getIp6().ip6Address)))
.findFirst()
- .ifPresent(ipNeighborDetails -> builder.setIp(arrayToIpv6AddressNoZone(ipNeighborDetails.ipAddress))
+ .ifPresent(ipNeighborDetails -> builder.setIp(arrayToIpv6AddressNoZone(
+ ipNeighborDetails.neighbor.ipAddress.un.getIp6().ip6Address))
.withKey(keyMapper().apply(ipNeighborDetails))
- .setLinkLayerAddress(toPhysAddress(ipNeighborDetails.macAddress)));
+ .setLinkLayerAddress(toPhysAddress(ipNeighborDetails.neighbor.macAddress.macaddress)));
}
}
@@ -87,6 +89,7 @@ public class SubInterfaceIpv6NeighbourCustomizer extends IpNeighbourReader
}
private Function<IpNeighborDetails, NeighborKey> keyMapper() {
- return ipNeighborDetails -> new NeighborKey(arrayToIpv6AddressNoZone(ipNeighborDetails.ipAddress));
+ return ipNeighborDetails -> new NeighborKey(
+ arrayToIpv6AddressNoZone(ipNeighborDetails.neighbor.ipAddress.un.getIp6().ip6Address));
}
}
diff --git a/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv4/Ipv4NeighbourCustomizer.java b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv4/Ipv4NeighbourCustomizer.java
index f8edcfb15..d5988fa9c 100644
--- a/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv4/Ipv4NeighbourCustomizer.java
+++ b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv4/Ipv4NeighbourCustomizer.java
@@ -61,11 +61,11 @@ public class Ipv4NeighbourCustomizer extends FutureJVppCustomizer
LOG.debug("Processing request for Neighbour {} write", id);
addDelNeighbour(id, () -> {
- IpNeighborAddDel request = preBindIpv4Request(true);
+ IpNeighborAddDel request = preBindRequest(true);
- request.dstAddress = ipv4AddressNoZoneToArray(data.getIp());
- request.macAddress = parseMac(data.getLinkLayerAddress().getValue());
- request.swIfIndex = interfaceContext
+ request.neighbor.macAddress = parseMacAddress(data.getLinkLayerAddress().getValue());
+ request.neighbor.ipAddress = ipv4AddressNoZoneToAddress(data.getIp());
+ request.neighbor.swIfIndex = interfaceContext
.getIndex(id.firstKeyOf(Interface.class).getName(), writeContext.getMappingContext());
return request;
}, getFutureJVpp());
@@ -80,11 +80,11 @@ public class Ipv4NeighbourCustomizer extends FutureJVppCustomizer
LOG.debug("Processing request for Neighbour {} delete", id);
addDelNeighbour(id, () -> {
- IpNeighborAddDel request = preBindIpv4Request(false);
+ IpNeighborAddDel request = preBindRequest(false);
- request.dstAddress = ipv4AddressNoZoneToArray(data.getIp());
- request.macAddress = parseMac(data.getLinkLayerAddress().getValue());
- request.swIfIndex = interfaceContext
+ request.neighbor.macAddress = parseMacAddress(data.getLinkLayerAddress().getValue());
+ request.neighbor.ipAddress = ipv4AddressNoZoneToAddress(data.getIp());
+ request.neighbor.swIfIndex = interfaceContext
.getIndex(id.firstKeyOf(Interface.class).getName(), writeContext.getMappingContext());
return request;
}, getFutureJVpp());
diff --git a/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv4/ProxyRangeCustomizer.java b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv4/ProxyRangeCustomizer.java
index 79d0e55e5..461de46c3 100644
--- a/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv4/ProxyRangeCustomizer.java
+++ b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv4/ProxyRangeCustomizer.java
@@ -25,6 +25,7 @@ import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.ProxyArpAddDel;
import io.fd.vpp.jvpp.core.dto.ProxyArpAddDelReply;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import io.fd.vpp.jvpp.core.types.Ip4Address;
import io.fd.vpp.jvpp.core.types.ProxyArp;
import java.util.concurrent.Future;
import javax.annotation.Nonnull;
@@ -88,9 +89,11 @@ public class ProxyRangeCustomizer extends FutureJVppCustomizer
final ProxyArpAddDel proxyArpAddDel = new ProxyArpAddDel();
proxyArpAddDel.isAdd = isAdd;
proxyArpAddDel.proxy = new ProxyArp();
- proxyArpAddDel.proxy.lowAddress = Ipv4Translator.INSTANCE.ipv4AddressNoZoneToArray(lAddr);
- proxyArpAddDel.proxy.hiAddress = Ipv4Translator.INSTANCE.ipv4AddressNoZoneToArray(hAddr);
- proxyArpAddDel.proxy.vrfId = vrfId;
+ proxyArpAddDel.proxy.low = new Ip4Address();
+ proxyArpAddDel.proxy.low.ip4Address = Ipv4Translator.INSTANCE.ipv4AddressNoZoneToArray(lAddr);
+ proxyArpAddDel.proxy.hi = new Ip4Address();
+ proxyArpAddDel.proxy.hi.ip4Address = Ipv4Translator.INSTANCE.ipv4AddressNoZoneToArray(hAddr);
+ proxyArpAddDel.proxy.tableId = vrfId;
return proxyArpAddDel;
}
}
diff --git a/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv4/subinterface/SubInterfaceIpv4NeighbourCustomizer.java b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv4/subinterface/SubInterfaceIpv4NeighbourCustomizer.java
index 61685af9c..89d6dbf51 100644
--- a/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv4/subinterface/SubInterfaceIpv4NeighbourCustomizer.java
+++ b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv4/subinterface/SubInterfaceIpv4NeighbourCustomizer.java
@@ -55,11 +55,11 @@ public class SubInterfaceIpv4NeighbourCustomizer extends FutureJVppCustomizer
LOG.debug("Processing request for Neighbour {} write", id);
addDelNeighbour(id, () -> {
- IpNeighborAddDel request = preBindIpv4Request(true);
+ IpNeighborAddDel request = preBindRequest(true);
- request.dstAddress = ipv4AddressNoZoneToArray(data.getIp());
- request.macAddress = parseMac(data.getLinkLayerAddress().getValue());
- request.swIfIndex = subInterfaceIndex(id, interfaceContext, writeContext.getMappingContext());
+ request.neighbor.macAddress = parseMacAddress(data.getLinkLayerAddress().getValue());
+ request.neighbor.ipAddress = ipv4AddressNoZoneToAddress(data.getIp());
+ request.neighbor.swIfIndex = subInterfaceIndex(id, interfaceContext, writeContext.getMappingContext());
// we don't have support for sub-interface routing, so not setting vrf
return request;
@@ -75,11 +75,11 @@ public class SubInterfaceIpv4NeighbourCustomizer extends FutureJVppCustomizer
LOG.debug("Processing request for Neighbour {} delete", id);
addDelNeighbour(id, () -> {
- IpNeighborAddDel request = preBindIpv4Request(false);
+ IpNeighborAddDel request = preBindRequest(false);
- request.dstAddress = ipv4AddressNoZoneToArray(data.getIp());
- request.macAddress = parseMac(data.getLinkLayerAddress().getValue());
- request.swIfIndex = subInterfaceIndex(id, interfaceContext, writeContext.getMappingContext());
+ request.neighbor.macAddress = parseMacAddress(data.getLinkLayerAddress().getValue());
+ request.neighbor.ipAddress = ipv4AddressNoZoneToAddress(data.getIp());
+ request.neighbor.swIfIndex = subInterfaceIndex(id, interfaceContext, writeContext.getMappingContext());
//TODO HONEYCOMB-182 if it is necessary for future use ,make adjustments to be able to set vrfid
//request.vrfId
diff --git a/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6NeighbourCustomizer.java b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6NeighbourCustomizer.java
index ed06ab08f..f7105088d 100644
--- a/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6NeighbourCustomizer.java
+++ b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6NeighbourCustomizer.java
@@ -25,12 +25,14 @@ import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.l3.utils.ip.write.IpWriter;
import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.IpNeighborAddDel;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import io.fd.vpp.jvpp.core.types.IpNeighborFlags;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv6.Neighbor;
@@ -40,7 +42,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Ipv6NeighbourCustomizer extends FutureJVppCustomizer
- implements ListWriterCustomizer<Neighbor, NeighborKey>, ByteDataTranslator, AddressTranslator,
+ implements ListWriterCustomizer<Neighbor, NeighborKey>, ByteDataTranslator, AddressTranslator, IpWriter,
JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(Ipv6NeighbourCustomizer.class);
@@ -59,7 +61,7 @@ public class Ipv6NeighbourCustomizer extends FutureJVppCustomizer
checkNotNull(dataAfter, "Cannot write null neighbour");
checkArgument(id.firstKeyOf(Interface.class) != null, "No parent interface key found");
- LOG.debug("Processing request for Neigbour write");
+ LOG.debug("Processing request for Neighbour write");
String interfaceName = id.firstKeyOf(Interface.class).getName();
MappingContext mappingContext = writeContext.getMappingContext();
@@ -79,7 +81,7 @@ public class Ipv6NeighbourCustomizer extends FutureJVppCustomizer
checkNotNull(dataBefore, "Cannot delete null neighbour");
checkArgument(id.firstKeyOf(Interface.class) != null, "No parent interface key found");
- LOG.debug("Processing request for Neigbour delete");
+ LOG.debug("Processing request for Neighbour delete");
String interfaceName = id.firstKeyOf(Interface.class).getName();
MappingContext mappingContext = writeContext.getMappingContext();
@@ -94,15 +96,13 @@ public class Ipv6NeighbourCustomizer extends FutureJVppCustomizer
private void addDelNeighbourAndReply(InstanceIdentifier<Neighbor> id, boolean add, int parentInterfaceIndex,
Neighbor data) throws WriteFailedException {
-
- IpNeighborAddDel request = new IpNeighborAddDel();
-
- request.isAdd = booleanToByte(add);
- request.isIpv6 = 1;
- request.isStatic = 1;
- request.dstAddress = ipv6AddressNoZoneToArray(data.getIp());
- request.macAddress = parseMac(data.getLinkLayerAddress().getValue());
- request.swIfIndex = parentInterfaceIndex;
- getReplyForWrite(getFutureJVpp().ipNeighborAddDel(request).toCompletableFuture(), id);
+ addDelNeighbour(id, () -> {
+ IpNeighborAddDel request = preBindRequest(add);
+ request.neighbor.flags = IpNeighborFlags.IP_API_NEIGHBOR_FLAG_STATIC;
+ request.neighbor.macAddress = parseMacAddress(data.getLinkLayerAddress().getValue());
+ request.neighbor.ipAddress = ipv6AddressToAddress(data.getIp());
+ request.neighbor.swIfIndex = parentInterfaceIndex;
+ return request;
+ }, getFutureJVpp());
}
}
diff --git a/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/nd/NdProxyCustomizer.java b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/nd/NdProxyCustomizer.java
index ca6e2bf87..23556a468 100644
--- a/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/nd/NdProxyCustomizer.java
+++ b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/nd/NdProxyCustomizer.java
@@ -27,6 +27,7 @@ import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.Ip6NdProxyAddDel;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import io.fd.vpp.jvpp.core.types.Ip6Address;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.nd.proxy.rev170315.interfaces._interface.ipv6.nd.proxies.NdProxy;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.nd.proxy.rev170315.interfaces._interface.ipv6.nd.proxies.NdProxyKey;
@@ -76,7 +77,8 @@ public final class NdProxyCustomizer extends FutureJVppCustomizer
final Ip6NdProxyAddDel request = new Ip6NdProxyAddDel();
request.swIfIndex = swIfIndex;
- request.address = addressBytes;
+ request.ip = new Ip6Address();
+ request.ip.ip6Address = addressBytes;
request.isDel = booleanToByte(!add);
getReplyForWrite(getFutureJVpp().ip6NdProxyAddDel(request).toCompletableFuture(), id);
diff --git a/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/subinterface/SubInterfaceIpv6NeighbourCustomizer.java b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/subinterface/SubInterfaceIpv6NeighbourCustomizer.java
index 3fc43f76b..00e499f92 100644
--- a/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/subinterface/SubInterfaceIpv6NeighbourCustomizer.java
+++ b/l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/subinterface/SubInterfaceIpv6NeighbourCustomizer.java
@@ -55,11 +55,10 @@ public class SubInterfaceIpv6NeighbourCustomizer extends FutureJVppCustomizer
LOG.debug("Processing request for Neighbour {} write", id);
addDelNeighbour(id, () -> {
- IpNeighborAddDel request = preBindIpv6Request(true);
-
- request.dstAddress = ipv6AddressNoZoneToArray(data.getIp());
- request.macAddress = parseMac(data.getLinkLayerAddress().getValue());
- request.swIfIndex = subInterfaceIndex(id, interfaceContext, writeContext.getMappingContext());
+ IpNeighborAddDel request = preBindRequest(true);
+ request.neighbor.macAddress = parseMacAddress(data.getLinkLayerAddress().getValue());
+ request.neighbor.ipAddress = ipv6AddressToAddress(data.getIp());
+ request.neighbor.swIfIndex = subInterfaceIndex(id, interfaceContext, writeContext.getMappingContext());
// we don't have support for sub-interface routing, so not setting vrf
return request;
@@ -75,11 +74,10 @@ public class SubInterfaceIpv6NeighbourCustomizer extends FutureJVppCustomizer
LOG.debug("Processing request for Neighbour {} delete", id);
addDelNeighbour(id, () -> {
- IpNeighborAddDel request = preBindIpv6Request(false);
-
- request.dstAddress = ipv6AddressNoZoneToArray(data.getIp());
- request.macAddress = parseMac(data.getLinkLayerAddress().getValue());
- request.swIfIndex = subInterfaceIndex(id, interfaceContext, writeContext.getMappingContext());
+ IpNeighborAddDel request = preBindRequest(false);
+ request.neighbor.macAddress = parseMacAddress(data.getLinkLayerAddress().getValue());
+ request.neighbor.ipAddress = ipv6AddressToAddress(data.getIp());
+ request.neighbor.swIfIndex = subInterfaceIndex(id, interfaceContext, writeContext.getMappingContext());
//TODO HONEYCOMB-182 if it is necessary for future use ,make adjustments to be able to set vrfid
//request.vrfId
diff --git a/l3/impl/src/test/java/io/fd/hc2vpp/l3/read/InterfaceChildNodeTest.java b/l3/impl/src/test/java/io/fd/hc2vpp/l3/read/InterfaceChildNodeTest.java
index 48a1b7327..9534ac966 100644
--- a/l3/impl/src/test/java/io/fd/hc2vpp/l3/read/InterfaceChildNodeTest.java
+++ b/l3/impl/src/test/java/io/fd/hc2vpp/l3/read/InterfaceChildNodeTest.java
@@ -31,6 +31,13 @@ import io.fd.vpp.jvpp.core.dto.IpNeighborDetails;
import io.fd.vpp.jvpp.core.dto.IpNeighborDetailsReplyDump;
import io.fd.vpp.jvpp.core.dto.IpNeighborDump;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import io.fd.vpp.jvpp.core.types.Address;
+import io.fd.vpp.jvpp.core.types.AddressFamily;
+import io.fd.vpp.jvpp.core.types.AddressUnion;
+import io.fd.vpp.jvpp.core.types.Ip4Address;
+import io.fd.vpp.jvpp.core.types.Ip6Address;
+import io.fd.vpp.jvpp.core.types.IpNeighbor;
+import io.fd.vpp.jvpp.core.types.MacAddress;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nonnull;
@@ -185,9 +192,23 @@ public interface InterfaceChildNodeTest extends NamingContextHelper, FutureProdu
static IpNeighborDetails neighborDump(byte[] address, int isIpv6, byte[] mac) {
IpNeighborDetails detail = new IpNeighborDetails();
- detail.ipAddress = address;
- detail.isIpv6 = (byte) isIpv6;
- detail.macAddress = mac;
+ detail.neighbor = new IpNeighbor();
+ detail.neighbor.ipAddress = new Address();
+ AddressUnion addressUnion;
+ if (isIpv6 == 1) {
+ Ip6Address ip6Address = new Ip6Address();
+ ip6Address.ip6Address = address;
+ addressUnion =new AddressUnion(ip6Address);
+ detail.neighbor.ipAddress.af = AddressFamily.ADDRESS_IP6;
+ } else {
+ Ip4Address ip4Address = new Ip4Address();
+ ip4Address.ip4Address = address;
+ addressUnion =new AddressUnion(ip4Address);
+ detail.neighbor.ipAddress.af = AddressFamily.ADDRESS_IP4;
+ }
+ detail.neighbor.ipAddress.un = addressUnion;
+ detail.neighbor.macAddress = new MacAddress();
+ detail.neighbor.macAddress.macaddress = mac;
return detail;
}
diff --git a/l3/impl/src/test/java/io/fd/hc2vpp/l3/read/ipv6/nd/NdProxyCustomizerTest.java b/l3/impl/src/test/java/io/fd/hc2vpp/l3/read/ipv6/nd/NdProxyCustomizerTest.java
index bc4cab554..a29250783 100644
--- a/l3/impl/src/test/java/io/fd/hc2vpp/l3/read/ipv6/nd/NdProxyCustomizerTest.java
+++ b/l3/impl/src/test/java/io/fd/hc2vpp/l3/read/ipv6/nd/NdProxyCustomizerTest.java
@@ -29,6 +29,7 @@ import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.vpp.jvpp.core.dto.Ip6NdProxyDetails;
import io.fd.vpp.jvpp.core.dto.Ip6NdProxyDetailsReplyDump;
+import io.fd.vpp.jvpp.core.types.Ip6Address;
import java.util.List;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.nd.proxy.rev170315.NdProxyIp6StateAugmentation;
@@ -63,13 +64,16 @@ public class NdProxyCustomizerTest extends InitializingListReaderCustomizerTest<
final Ip6NdProxyDetailsReplyDump reply = new Ip6NdProxyDetailsReplyDump();
final Ip6NdProxyDetails proxy1 = new Ip6NdProxyDetails();
proxy1.swIfIndex = IF1_INDEX;
- proxy1.address = new byte[] {0x20, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01};
+ proxy1.ip = new Ip6Address();
+ proxy1.ip.ip6Address = new byte[] {0x20, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01};
final Ip6NdProxyDetails proxy2 = new Ip6NdProxyDetails();
proxy2.swIfIndex = IF1_INDEX;
- proxy2.address = new byte[] {0x20, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x02};
+ proxy2.ip = new Ip6Address();
+ proxy2.ip.ip6Address = new byte[] {0x20, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x02};
final Ip6NdProxyDetails proxy3 = new Ip6NdProxyDetails();
proxy3.swIfIndex = IF2_INDEX;
- proxy3.address = new byte[] {0x20, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x03};
+ proxy3.ip = new Ip6Address();
+ proxy3.ip.ip6Address = new byte[] {0x20, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x03};
reply.ip6NdProxyDetails.add(proxy1);
reply.ip6NdProxyDetails.add(proxy2);
reply.ip6NdProxyDetails.add(proxy3);
diff --git a/l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ProxyRangeCustomizerTest.java b/l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ProxyRangeCustomizerTest.java
index 5a0de6667..eda79fc83 100644
--- a/l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ProxyRangeCustomizerTest.java
+++ b/l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ProxyRangeCustomizerTest.java
@@ -26,6 +26,7 @@ import io.fd.hc2vpp.l3.write.ipv4.ProxyRangeCustomizer;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.ProxyArpAddDel;
import io.fd.vpp.jvpp.core.dto.ProxyArpAddDelReply;
+import io.fd.vpp.jvpp.core.types.Ip4Address;
import io.fd.vpp.jvpp.core.types.ProxyArp;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.proxy.arp.rev180703.ProxyRanges;
@@ -90,9 +91,11 @@ public class ProxyRangeCustomizerTest extends WriterCustomizerTest implements By
final ProxyArpAddDel request = new ProxyArpAddDel();
request.isAdd = booleanToByte(isAdd);
request.proxy = new ProxyArp();
- request.proxy.vrfId = 123;
- request.proxy.lowAddress = new byte[] {10, 1, 1, 1};
- request.proxy.hiAddress = new byte[] {10, 1, 1, 2};
+ request.proxy.tableId = 123;
+ request.proxy.low = new Ip4Address();
+ request.proxy.low.ip4Address = new byte[] {10, 1, 1, 1};
+ request.proxy.hi = new Ip4Address();
+ request.proxy.hi.ip4Address = new byte[] {10, 1, 1, 2};
return request;
}
}
diff --git a/l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ipv4/Ipv4NeighbourCustomizerTest.java b/l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ipv4/Ipv4NeighbourCustomizerTest.java
index bab261a31..7d2b6472c 100644
--- a/l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ipv4/Ipv4NeighbourCustomizerTest.java
+++ b/l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ipv4/Ipv4NeighbourCustomizerTest.java
@@ -30,6 +30,13 @@ import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.VppBaseCallException;
import io.fd.vpp.jvpp.core.dto.IpNeighborAddDel;
import io.fd.vpp.jvpp.core.dto.IpNeighborAddDelReply;
+import io.fd.vpp.jvpp.core.types.Address;
+import io.fd.vpp.jvpp.core.types.AddressFamily;
+import io.fd.vpp.jvpp.core.types.AddressUnion;
+import io.fd.vpp.jvpp.core.types.Ip4Address;
+import io.fd.vpp.jvpp.core.types.IpNeighbor;
+import io.fd.vpp.jvpp.core.types.IpNeighborFlags;
+import io.fd.vpp.jvpp.core.types.MacAddress;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
@@ -120,12 +127,18 @@ public class Ipv4NeighbourCustomizerTest extends WriterCustomizerTest implements
}
private IpNeighborAddDel getExpectedRequest(final boolean isAdd) {
final IpNeighborAddDel request = new IpNeighborAddDel();
- request.isIpv6 = 0;
+ request.neighbor = new IpNeighbor();
+ request.neighbor.macAddress = new MacAddress();
+ request.neighbor.macAddress.macaddress =
+ new byte[]{(byte) 0xaa, (byte) 0xbb, (byte) 0xcc, (byte) 0xee, 0x11, 0x22};
+ request.neighbor.ipAddress = new Address();
+ request.neighbor.ipAddress.af = AddressFamily.ADDRESS_IP4;
+ Ip4Address ip4Address = new Ip4Address();
+ ip4Address.ip4Address = new byte[]{(byte) 192, (byte) 168, 2, 1};
+ request.neighbor.ipAddress.un = new AddressUnion(ip4Address);
request.isAdd = booleanToByte(isAdd);
- request.isStatic = 1;
- request.dstAddress = new byte[] {(byte) 192, (byte) 168, 2, 1};
- request.macAddress = new byte[] {(byte) 0xaa, (byte) 0xbb, (byte) 0xcc, (byte) 0xee, 0x11, 0x22};
- request.swIfIndex = IFACE_ID;
+ request.neighbor.flags = IpNeighborFlags.IP_API_NEIGHBOR_FLAG_STATIC;
+ request.neighbor.swIfIndex = IFACE_ID;
return request;
}
} \ No newline at end of file
diff --git a/l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6NeighbourCustomizerTest.java b/l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6NeighbourCustomizerTest.java
index 5f11a5d5c..ec8734cf7 100644
--- a/l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6NeighbourCustomizerTest.java
+++ b/l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6NeighbourCustomizerTest.java
@@ -29,6 +29,13 @@ import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.VppBaseCallException;
import io.fd.vpp.jvpp.core.dto.IpNeighborAddDel;
import io.fd.vpp.jvpp.core.dto.IpNeighborAddDelReply;
+import io.fd.vpp.jvpp.core.types.Address;
+import io.fd.vpp.jvpp.core.types.AddressFamily;
+import io.fd.vpp.jvpp.core.types.AddressUnion;
+import io.fd.vpp.jvpp.core.types.Ip6Address;
+import io.fd.vpp.jvpp.core.types.IpNeighbor;
+import io.fd.vpp.jvpp.core.types.IpNeighborFlags;
+import io.fd.vpp.jvpp.core.types.MacAddress;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone;
@@ -121,12 +128,18 @@ public class Ipv6NeighbourCustomizerTest extends WriterCustomizerTest implements
private IpNeighborAddDel getExpectedRequest(final boolean isAdd) {
final IpNeighborAddDel request = new IpNeighborAddDel();
- request.isIpv6 = 1;
request.isAdd = booleanToByte(isAdd);
- request.isStatic = 1;
- request.dstAddress = new byte[]{32, 1, 13, -72, 10, 11, 18, -16, 0, 0, 0, 0, 0, 0, 0, 1};
- request.macAddress = new byte[]{(byte) 0xaa, (byte) 0xbb, (byte) 0xcc, (byte) 0xee, 0x11, 0x22};
- request.swIfIndex = IFACE_ID;
+ request.neighbor = new IpNeighbor();
+ request.neighbor.macAddress = new MacAddress();
+ request.neighbor.macAddress.macaddress =
+ new byte[]{(byte) 0xaa, (byte) 0xbb, (byte) 0xcc, (byte) 0xee, 0x11, 0x22};
+ request.neighbor.ipAddress = new Address();
+ request.neighbor.ipAddress.af = AddressFamily.ADDRESS_IP6;
+ Ip6Address ip6Address = new Ip6Address();
+ ip6Address.ip6Address = new byte[]{32, 1, 13, -72, 10, 11, 18, -16, 0, 0, 0, 0, 0, 0, 0, 1};
+ request.neighbor.ipAddress.un = new AddressUnion(ip6Address);
+ request.neighbor.flags = IpNeighborFlags.IP_API_NEIGHBOR_FLAG_STATIC;
+ request.neighbor.swIfIndex = IFACE_ID;
return request;
}
diff --git a/l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ipv6/nd/NdProxyCustomizerTest.java b/l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ipv6/nd/NdProxyCustomizerTest.java
index 1bdad2e2e..582b8e916 100644
--- a/l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ipv6/nd/NdProxyCustomizerTest.java
+++ b/l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ipv6/nd/NdProxyCustomizerTest.java
@@ -26,6 +26,7 @@ import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.Ip6NdProxyAddDel;
import io.fd.vpp.jvpp.core.dto.Ip6NdProxyAddDelReply;
+import io.fd.vpp.jvpp.core.types.Ip6Address;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.nd.proxy.rev170315.NdProxyIp6Augmentation;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.nd.proxy.rev170315.interfaces._interface.ipv6.NdProxies;
@@ -66,7 +67,8 @@ public class NdProxyCustomizerTest extends WriterCustomizerTest {
customizer.writeCurrentAttributes(getId(address), data, writeContext);
final Ip6NdProxyAddDel request = new Ip6NdProxyAddDel();
request.swIfIndex = IF_INDEX;
- request.address = new byte[] {0x20, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01};
+ request.ip = new Ip6Address();
+ request.ip.ip6Address = new byte[] {0x20, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01};
verify(api).ip6NdProxyAddDel(request);
}
@@ -85,7 +87,8 @@ public class NdProxyCustomizerTest extends WriterCustomizerTest {
final Ip6NdProxyAddDel request = new Ip6NdProxyAddDel();
request.isDel = 1;
request.swIfIndex = IF_INDEX;
- request.address = new byte[] {0x20, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x03};
+ request.ip = new Ip6Address();
+ request.ip.ip6Address = new byte[] {0x20, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x03};
verify(api).ip6NdProxyAddDel(request);
}
diff --git a/l3/utils/src/main/java/io/fd/hc2vpp/l3/utils/ip/write/IpWriter.java b/l3/utils/src/main/java/io/fd/hc2vpp/l3/utils/ip/write/IpWriter.java
index d3b328cd3..00e34d3cc 100644
--- a/l3/utils/src/main/java/io/fd/hc2vpp/l3/utils/ip/write/IpWriter.java
+++ b/l3/utils/src/main/java/io/fd/hc2vpp/l3/utils/ip/write/IpWriter.java
@@ -29,6 +29,8 @@ import io.fd.vpp.jvpp.core.dto.IpNeighborAddDel;
import io.fd.vpp.jvpp.core.dto.SwInterfaceAddDelAddress;
import io.fd.vpp.jvpp.core.dto.SwInterfaceAddDelAddressReply;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import io.fd.vpp.jvpp.core.types.IpNeighbor;
+import io.fd.vpp.jvpp.core.types.IpNeighborFlags;
import java.util.concurrent.CompletionStage;
import java.util.function.Supplier;
import javax.annotation.Nonnegative;
@@ -142,25 +144,11 @@ public interface IpWriter extends ByteDataTranslator, AddressTranslator, JvppRep
getReplyForWrite(api.ipNeighborAddDel(requestSupplier.get()).toCompletableFuture(), id);
}
- default IpNeighborAddDel preBindIpv4Request(final boolean add) {
- IpNeighborAddDel request = staticPreBindRequest(add);
- request.isIpv6 = 0;
-
- return request;
- }
-
- default IpNeighborAddDel preBindIpv6Request(final boolean add) {
- IpNeighborAddDel request = staticPreBindRequest(add);
- request.isIpv6 = 1;
-
- return request;
- }
-
- static IpNeighborAddDel staticPreBindRequest(final boolean add) {
+ default IpNeighborAddDel preBindRequest(final boolean add) {
IpNeighborAddDel request = new IpNeighborAddDel();
-
+ request.neighbor = new IpNeighbor();
request.isAdd = ByteDataTranslator.INSTANCE.booleanToByte(add);
- request.isStatic = 1;
+ request.neighbor.flags = IpNeighborFlags.IP_API_NEIGHBOR_FLAG_STATIC;
return request;
}
}
diff --git a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/PrefixCustomizer.java b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/PrefixCustomizer.java
index 51a43ca55..e818be893 100644
--- a/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/PrefixCustomizer.java
+++ b/routing/routing-impl/src/main/java/io/fd/hc2vpp/routing/write/PrefixCustomizer.java
@@ -82,8 +82,7 @@ final class PrefixCustomizer extends FutureJVppCustomizer
final int ifcIndex = interfaceContext.getIndex(ifcName, writeContext.getMappingContext());
final SwInterfaceIp6NdRaPrefix request = new SwInterfaceIp6NdRaPrefix();
request.swIfIndex = ifcIndex;
- request.address = ipv6AddressPrefixToArray(prefix.getPrefixSpec());
- request.addressLength = extractPrefix(prefix.getPrefixSpec()); // prefix length (vpp api naming bug)
+ request.prefix = ipv6AddressPrefixToPrefix(prefix.getPrefixSpec());
if (isDelete) {
request.isNo = 1;
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/PrefixCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/PrefixCustomizerTest.java
index 7321acde5..3f99b791d 100644
--- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/PrefixCustomizerTest.java
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/PrefixCustomizerTest.java
@@ -29,6 +29,10 @@ import io.fd.honeycomb.test.tools.annotations.InjectTestData;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.vpp.jvpp.core.dto.SwInterfaceIp6NdRaPrefix;
import io.fd.vpp.jvpp.core.dto.SwInterfaceIp6NdRaPrefixReply;
+import io.fd.vpp.jvpp.core.types.Address;
+import io.fd.vpp.jvpp.core.types.AddressFamily;
+import io.fd.vpp.jvpp.core.types.AddressUnion;
+import io.fd.vpp.jvpp.core.types.Ip6Address;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
@@ -82,14 +86,26 @@ public class PrefixCustomizerTest extends WriterCustomizerTest implements Schema
request.swIfIndex = IFC_INDEX;
// 2001:0db8:0a0b:12f0:0000:0000:0000:0002/64
- request.address =
- new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, 0x0a, 0x0b, 0x12, (byte) 0xf0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02};
- request.addressLength = 64;
+ request.prefix = getPrefix(
+ new byte[]{0x20, 0x01, 0x0d, (byte) 0xb8, 0x0a, 0x0b, 0x12, (byte) 0xf0, 0, 0, 0, 0, 0, 0, 0, 0x02},
+ (byte) 64);
request.valLifetime = 2592000; // default value
request.prefLifetime = 604800; // default value
verify(api).swInterfaceIp6NdRaPrefix(request);
}
+ public io.fd.vpp.jvpp.core.types.Prefix getPrefix(byte[] ip6address, byte length) {
+ io.fd.vpp.jvpp.core.types.Prefix prefix = new io.fd.vpp.jvpp.core.types.Prefix();
+ Address address = new Address();
+ address.af = AddressFamily.ADDRESS_IP6;
+ Ip6Address ip6Address = new Ip6Address();
+ ip6Address.ip6Address = ip6address;
+ address.un = new AddressUnion(ip6Address);
+ prefix.addressLength = length;
+ prefix.address = address;
+ return prefix;
+ }
+
@Test
public void testUpdate(@InjectTestData(resourcePath = "/ra/complexPrefix.json", id = RA_PATH) PrefixList prefixList)
throws WriteFailedException {
@@ -99,9 +115,9 @@ public class PrefixCustomizerTest extends WriterCustomizerTest implements Schema
request.swIfIndex = IFC_INDEX;
// 2001:0db8:0a0b:12f0:0000:0000:0000:0002/64
- request.address =
- new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, 0x0a, 0x0b, 0x12, (byte) 0xf0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02};
- request.addressLength = 64;
+ request.prefix = getPrefix(
+ new byte[]{0x20, 0x01, 0x0d, (byte) 0xb8, 0x0a, 0x0b, 0x12, (byte) 0xf0, 0, 0, 0, 0, 0, 0, 0, 0x02},
+ (byte) 64);
request.noAdvertise = 1;
request.noAutoconfig = 1;
request.valLifetime = -1;
@@ -117,9 +133,9 @@ public class PrefixCustomizerTest extends WriterCustomizerTest implements Schema
final SwInterfaceIp6NdRaPrefix request = new SwInterfaceIp6NdRaPrefix();
request.swIfIndex = IFC_INDEX;
// 2001:0db8:0a0b:12f0:0000:0000:0000:0002/64
- request.address =
- new byte[] {0x20, 0x01, 0x0d, (byte) 0xb8, 0x0a, 0x0b, 0x12, (byte) 0xf0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0x02};
- request.addressLength = 64;
+ request.prefix = getPrefix(
+ new byte[]{0x20, 0x01, 0x0d, (byte) 0xb8, 0x0a, 0x0b, 0x12, (byte) 0xf0, 0, 0, 0, 0, 0, 0, 0, 0x02},
+ (byte) 64);
request.isNo = 1;
verify(api).swInterfaceIp6NdRaPrefix(request);
}
diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/Ipv4Translator.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/Ipv4Translator.java
index 24f4ae9aa..5f8a283ed 100644
--- a/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/Ipv4Translator.java
+++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/Ipv4Translator.java
@@ -18,9 +18,14 @@ package io.fd.hc2vpp.common.translate.util;
import static com.google.common.base.Preconditions.checkNotNull;
+import io.fd.vpp.jvpp.core.types.Address;
+import io.fd.vpp.jvpp.core.types.AddressFamily;
+import io.fd.vpp.jvpp.core.types.AddressUnion;
+import io.fd.vpp.jvpp.core.types.Ip4Address;
import java.util.Arrays;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
@@ -83,6 +88,34 @@ public interface Ipv4Translator extends ByteDataTranslator {
return ipv4AddressNoZoneToArray(ipv4Addr.getValue());
}
+ /**
+ * Transform Ipv4 address to a Ip4Address acceptable by VPP.
+ *
+ * @return byte array with address bytes
+ */
+ default Address ipv4AddressNoZoneToAddress(final Ipv4AddressNoZone ipv4Addr) {
+ Address address = new Address();
+ address.af = AddressFamily.ADDRESS_IP4;
+ Ip4Address ip4Address = new Ip4Address();
+ ip4Address.ip4Address = ipv4AddressNoZoneToArray(ipv4Addr);
+ address.un = new AddressUnion(ip4Address);
+ return address;
+ }
+
+ /**
+ * Transform Ipv4 address to a Ip4Address acceptable by VPP.
+ *
+ * @return byte array with address bytes
+ */
+ default Address ipv4AddressToAddress(final Ipv4Address ipv4Addr) {
+ Address address = new Address();
+ address.af = AddressFamily.ADDRESS_IP4;
+ Ip4Address ip4Address = new Ip4Address();
+ ip4Address.ip4Address = ipv4AddressNoZoneToArray(ipv4Addr.getValue());
+ address.un = new AddressUnion(ip4Address);
+ return address;
+ }
+
default byte[] ipv4AddressNoZoneToArray(final String ipv4Addr) {
byte[] retval = new byte[4];
String[] dots = ipv4Addr.split("\\.");
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 b1199d7f7..d5c0ae2e3 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
@@ -21,6 +21,11 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import com.google.common.net.InetAddresses;
+import io.fd.vpp.jvpp.core.types.Address;
+import io.fd.vpp.jvpp.core.types.AddressFamily;
+import io.fd.vpp.jvpp.core.types.AddressUnion;
+import io.fd.vpp.jvpp.core.types.Ip6Address;
+import io.fd.vpp.jvpp.core.types.Prefix;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
@@ -46,7 +51,24 @@ public interface Ipv6Translator extends ByteDataTranslator {
}
/**
+ * Transform Ipv6 address to a Address acceptable by VPP.
+ *
+ * @param address {@link Ipv6Address} to be translated
+ * @return Vpp {@link Address} from Ipv6 address
+ */
+ default Address ipv6AddressToAddress(@Nonnull final Ipv6Address address) {
+ Address addr = new Address();
+ addr.af = AddressFamily.ADDRESS_IP6;
+ Ip6Address ip6Address = new Ip6Address();
+ ip6Address.ip6Address = ipv6AddressNoZoneToArray(address);
+ addr.un = new AddressUnion(ip6Address);
+ return addr;
+ }
+
+ /**
* Creates address array from address part of {@link Ipv6Prefix}
+ *
+ * @return Ipv6 address as byte array
*/
default byte[] ipv6AddressPrefixToArray(@Nonnull final Ipv6Prefix ipv6Prefix) {
checkNotNull(ipv6Prefix, "Cannot convert null prefix");
@@ -56,6 +78,23 @@ public interface Ipv6Translator extends ByteDataTranslator {
}
/**
+ * Transforms {@link Prefix} from {@link Ipv6Prefix}
+ * @param ipv6Prefix prefix to be translated
+ * @return Vpp {@link Prefix} from {@link Ipv6Prefix}
+ */
+ default Prefix ipv6AddressPrefixToPrefix(@Nonnull final Ipv6Prefix ipv6Prefix) {
+ checkNotNull(ipv6Prefix, "Cannot convert null prefix");
+ Prefix prefix = new Prefix();
+ prefix.address = new Address();
+ prefix.address.af = AddressFamily.ADDRESS_IP6;
+ Ip6Address ip6Address = new Ip6Address();
+ ip6Address.ip6Address = ipv6AddressPrefixToArray(ipv6Prefix);
+ prefix.address.un = new AddressUnion(ip6Address);
+ prefix.addressLength = extractPrefix(ipv6Prefix);
+ return prefix;
+ }
+
+ /**
* Extracts {@link Ipv6Prefix} prefix
*/
default byte extractPrefix(Ipv6Prefix data) {
diff --git a/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/MacTranslator.java b/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/MacTranslator.java
index 71b8a15e6..657029eb3 100644
--- a/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/MacTranslator.java
+++ b/vpp-common/vpp-translate-utils/src/main/java/io/fd/hc2vpp/common/translate/util/MacTranslator.java
@@ -20,6 +20,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Splitter;
+import io.fd.vpp.jvpp.core.types.MacAddress;
import java.util.Arrays;
import java.util.List;
import java.util.function.BiConsumer;
@@ -37,6 +38,9 @@ public interface MacTranslator {
/**
* Parse string represented mac address (using ":" as separator) into a byte array
+ *
+ * @param macAddress string representation of MAC address (using ":" as separator)
+ * @return byte array mac address
*/
@Nonnull
default byte[] parseMac(@Nonnull final String macAddress) {
@@ -45,6 +49,19 @@ public interface MacTranslator {
return parseMacLikeString(parts);
}
+ /**
+ * Parse string represented mac address (using ":" as separator) into a MacAddress in VPP
+ *
+ * @param macAddress string representation of MAC address (using ":" as separator)
+ * @return VPP MacAddress
+ */
+ @Nonnull
+ default MacAddress parseMacAddress(@Nonnull final String macAddress) {
+ MacAddress mac = new MacAddress();
+ mac.macaddress = parseMac(macAddress);
+ return mac;
+ }
+
default byte[] parseMacLikeString(final List<String> strings) {
return strings.stream().limit(6).map(this::parseHexByte).collect(
() -> new byte[strings.size()],