summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipsec/ipsec-impl/src/main/java/io/fd/hc2vpp/ipsec/write/IpsecSadEntryCustomizer.java12
-rw-r--r--ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/read/IpsecStateCustomizerTest.java5
-rw-r--r--ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/IpsecSadEntryCustomizerTest.java31
-rw-r--r--l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv4/Ipv4NeighbourCustomizer.java7
-rw-r--r--l3/impl/src/main/java/io/fd/hc2vpp/l3/read/ipv6/Ipv6NeighbourCustomizer.java7
-rw-r--r--l3/impl/src/main/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6NeighbourCustomizer.java3
-rw-r--r--l3/impl/src/test/java/io/fd/hc2vpp/l3/read/InterfaceChildNodeTest.java3
-rw-r--r--l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ipv4/Ipv4NeighbourCustomizerTest.java3
-rw-r--r--l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6NeighbourCustomizerTest.java3
-rw-r--r--l3/utils/src/main/java/io/fd/hc2vpp/l3/utils/ip/write/IpWriter.java3
10 files changed, 52 insertions, 25 deletions
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 1822b024f..d5b41cbe1 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
@@ -103,21 +103,17 @@ public class IpsecSadEntryCustomizer extends FutureJVppCustomizer
if (dataAfter.getSpi() != null) {
request.entry.spi = dataAfter.getSpi().intValue();
}
- request.entry.flags = IpsecSadFlags.IPSEC_API_SAD_FLAG_NONE;
+ request.entry.flags = new IpsecSadFlags();
if (dataAfter.getAntiReplayWindow() != null && dataAfter.getAntiReplayWindow() > 0) {
- request.entry.flags = IpsecSadFlags.IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY;
+ request.entry.flags.add(IpsecSadFlags.IpsecSadFlagsOptions.IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY);
}
-
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));
+ request.entry.flags.add(IpsecSadFlags.IpsecSadFlagsOptions.IPSEC_API_SAD_FLAG_IS_TUNNEL);
} 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));
+ request.entry.flags.add(IpsecSadFlags.IpsecSadFlagsOptions.IPSEC_API_SAD_FLAG_IS_TUNNEL_V6);
}
}
request.isAdd = adding
diff --git a/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/read/IpsecStateCustomizerTest.java b/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/read/IpsecStateCustomizerTest.java
index 46ebd89d8..53cbb4b3e 100644
--- a/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/read/IpsecStateCustomizerTest.java
+++ b/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/read/IpsecStateCustomizerTest.java
@@ -87,8 +87,9 @@ public class IpsecStateCustomizerTest extends ReaderCustomizerTest<IpsecState, I
saDetail.entry.protocol = IPSEC_API_PROTO_ESP;
saDetail.lastSeqInbound = LAST_SEQ_INB;
saDetail.replayWindow = REPLY_WINDOW;
- saDetail.entry.flags = IpsecSadFlags.forValue(IpsecSadFlags.IPSEC_API_SAD_FLAG_IS_TUNNEL.value +
- IpsecSadFlags.IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY.value);
+ saDetail.entry.flags = new IpsecSadFlags();
+ saDetail.entry.flags.add(IpsecSadFlags.IpsecSadFlagsOptions.IPSEC_API_SAD_FLAG_IS_TUNNEL);
+ saDetail.entry.flags.add(IpsecSadFlags.IpsecSadFlagsOptions.IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY);
saDetail.entry.tunnelSrc = ipv4AddressNoZoneToAddress(TUNNEL_SRC_ADDR);
saDetail.entry.tunnelDst = ipv4AddressNoZoneToAddress(TUNNEL_DST_ADDR);
saDetails.add(saDetail);
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 81588fea7..9f1ef23aa 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,7 +16,6 @@
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;
@@ -38,7 +37,6 @@ 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;
@@ -94,6 +92,27 @@ public class IpsecSadEntryCustomizerTest extends WriterCustomizerTest implements
}
@Test
+ public void testFlags() {
+ IpsecSadFlags flags = new IpsecSadFlags();
+ flags.add(IpsecSadFlags.IpsecSadFlagsOptions.IPSEC_API_SAD_FLAG_IS_TUNNEL);
+ flags.add(IpsecSadFlags.IpsecSadFlagsOptions.IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY);
+ flags.add(IpsecSadFlags.IpsecSadFlagsOptions.IPSEC_API_SAD_FLAG_USE_EXTENDED_SEQ_NUM);
+
+ IpsecSadFlags flags2 = new IpsecSadFlags();
+ flags2.add(IpsecSadFlags.IpsecSadFlagsOptions.IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY);
+ flags2.add(IpsecSadFlags.IpsecSadFlagsOptions.IPSEC_API_SAD_FLAG_USE_EXTENDED_SEQ_NUM);
+ flags2.add(IpsecSadFlags.IpsecSadFlagsOptions.IPSEC_API_SAD_FLAG_IS_TUNNEL);
+ ;
+ IpsecSadFlags flags3 = new IpsecSadFlags();
+ flags3.setOptionsValue(7);
+
+ assertEquals(4, IpsecSadFlags.IpsecSadFlagsOptions.IPSEC_API_SAD_FLAG_IS_TUNNEL.value);
+ assertEquals(flags, flags2);
+ assertEquals(7, flags.getOptionsValue());
+ assertEquals(flags, flags3);
+ }
+
+ @Test
public void testWrite(@InjectTestData(resourcePath = "/sadEntries/addDelSadEntry.json", id = SAD_PATH) Sad sad)
throws WriteFailedException {
final SadEntries data = sad.getSadEntries().get(0);
@@ -108,7 +127,8 @@ public class IpsecSadEntryCustomizerTest extends WriterCustomizerTest implements
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.flags = new IpsecSadFlags();
+ request.entry.flags.add(IpsecSadFlags.IpsecSadFlagsOptions.IPSEC_API_SAD_FLAG_IS_TUNNEL);
request.entry.tunnelSrc = ipv4AddressToAddress(TNL_SRC_ADDR);
request.entry.tunnelDst = ipv4AddressToAddress(TNL_DST_ADDR);
@@ -177,7 +197,8 @@ public class IpsecSadEntryCustomizerTest extends WriterCustomizerTest implements
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.flags = new IpsecSadFlags();
+ request.entry.flags.add(IpsecSadFlags.IpsecSadFlagsOptions.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);
@@ -194,7 +215,7 @@ public class IpsecSadEntryCustomizerTest extends WriterCustomizerTest implements
request.entry = new IpsecSadEntry();
request.entry.spi = SPI_1002;
request.entry.sadId = SAD_ID;
- request.entry.flags = IPSEC_API_SAD_FLAG_NONE;
+ request.entry.flags = new IpsecSadFlags();
verify(api).ipsecSadEntryAddDel(request);
}
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 1da148a31..e6f5e17b1 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
@@ -82,9 +82,10 @@ public class Ipv4NeighbourCustomizer extends IpNeighbourReader
ipNeighborDetails.neighbor.ipAddress.un.getIp4().ip4Address))
.withKey(keyMapper().apply(ipNeighborDetails))
.setLinkLayerAddress(toPhysAddress(ipNeighborDetails.neighbor.macAddress.macaddress))
- .setOrigin(ipNeighborDetails.neighbor.flags != IpNeighborFlags.IP_API_NEIGHBOR_FLAG_STATIC
- ? Dynamic
- : Static));
+ .setOrigin(ipNeighborDetails.neighbor.flags
+ .contains(IpNeighborFlags.IpNeighborFlagsOptions.IP_API_NEIGHBOR_FLAG_STATIC)
+ ? Static
+ : Dynamic));
}
}
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 92f4962ee..54eccce63 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
@@ -77,9 +77,10 @@ public class Ipv6NeighbourCustomizer extends IpNeighbourReader
ipNeighborDetails.neighbor.ipAddress.un.getIp6().ip6Address))
.withKey(keyMapper().apply(ipNeighborDetails))
.setLinkLayerAddress(toPhysAddress(ipNeighborDetails.neighbor.macAddress.macaddress))
- .setOrigin(ipNeighborDetails.neighbor.flags != IpNeighborFlags.IP_API_NEIGHBOR_FLAG_STATIC
- ? Dynamic
- : Static));
+ .setOrigin(ipNeighborDetails.neighbor.flags
+ .contains(IpNeighborFlags.IpNeighborFlagsOptions.IP_API_NEIGHBOR_FLAG_STATIC)
+ ? Static
+ : Dynamic));
}
}
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 f7105088d..f57965778 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
@@ -98,7 +98,8 @@ public class Ipv6NeighbourCustomizer extends FutureJVppCustomizer
Neighbor data) throws WriteFailedException {
addDelNeighbour(id, () -> {
IpNeighborAddDel request = preBindRequest(add);
- request.neighbor.flags = IpNeighborFlags.IP_API_NEIGHBOR_FLAG_STATIC;
+ request.neighbor.flags = new IpNeighborFlags();
+ request.neighbor.flags.add(IpNeighborFlags.IpNeighborFlagsOptions.IP_API_NEIGHBOR_FLAG_STATIC);
request.neighbor.macAddress = parseMacAddress(data.getLinkLayerAddress().getValue());
request.neighbor.ipAddress = ipv6AddressToAddress(data.getIp());
request.neighbor.swIfIndex = parentInterfaceIndex;
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 9534ac966..f58422066 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
@@ -37,6 +37,7 @@ 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.IpNeighborFlags;
import io.fd.vpp.jvpp.core.types.MacAddress;
import java.util.Arrays;
import java.util.List;
@@ -209,6 +210,8 @@ public interface InterfaceChildNodeTest extends NamingContextHelper, FutureProdu
detail.neighbor.ipAddress.un = addressUnion;
detail.neighbor.macAddress = new MacAddress();
detail.neighbor.macAddress.macaddress = mac;
+ detail.neighbor.flags = new IpNeighborFlags();
+ detail.neighbor.flags.add(IpNeighborFlags.IpNeighborFlagsOptions.IP_API_NEIGHBOR_FLAG_STATIC);
return detail;
}
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 7d2b6472c..cb87b5e3e 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
@@ -137,7 +137,8 @@ public class Ipv4NeighbourCustomizerTest extends WriterCustomizerTest implements
ip4Address.ip4Address = new byte[]{(byte) 192, (byte) 168, 2, 1};
request.neighbor.ipAddress.un = new AddressUnion(ip4Address);
request.isAdd = booleanToByte(isAdd);
- request.neighbor.flags = IpNeighborFlags.IP_API_NEIGHBOR_FLAG_STATIC;
+ request.neighbor.flags = new IpNeighborFlags();
+ request.neighbor.flags.add(IpNeighborFlags.IpNeighborFlagsOptions.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/Ipv6NeighbourCustomizerTest.java b/l3/impl/src/test/java/io/fd/hc2vpp/l3/write/ipv6/Ipv6NeighbourCustomizerTest.java
index ec8734cf7..f5f906155 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
@@ -138,7 +138,8 @@ public class Ipv6NeighbourCustomizerTest extends WriterCustomizerTest implements
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.flags = new IpNeighborFlags();
+ request.neighbor.flags.add(IpNeighborFlags.IpNeighborFlagsOptions.IP_API_NEIGHBOR_FLAG_STATIC);
request.neighbor.swIfIndex = IFACE_ID;
return 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 00e34d3cc..5bfdbd49b 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
@@ -148,7 +148,8 @@ public interface IpWriter extends ByteDataTranslator, AddressTranslator, JvppRep
IpNeighborAddDel request = new IpNeighborAddDel();
request.neighbor = new IpNeighbor();
request.isAdd = ByteDataTranslator.INSTANCE.booleanToByte(add);
- request.neighbor.flags = IpNeighborFlags.IP_API_NEIGHBOR_FLAG_STATIC;
+ request.neighbor.flags = new IpNeighborFlags();
+ request.neighbor.flags.add(IpNeighborFlags.IpNeighborFlagsOptions.IP_API_NEIGHBOR_FLAG_STATIC);
return request;
}
}