Issue #6728 - QUIC and HTTP/3

- Renamed Panama/JDK to Foreign/Incubator.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2021-11-08 19:38:06 +01:00
parent 4b49dbb54f
commit ec942f76bb
21 changed files with 89 additions and 96 deletions

View File

@ -23,7 +23,7 @@
<jdk>[17,)</jdk> <jdk>[17,)</jdk>
</activation> </activation>
<modules> <modules>
<module>quic-quiche-panama-jdk</module> <module>quic-quiche-foreign-incubator</module>
</modules> </modules>
</profile> </profile>
</profiles> </profiles>

View File

@ -34,21 +34,21 @@ public abstract class QuicheConnection
static static
{ {
LOG.info("found Quiche binding implementations: {}", TypeUtil.serviceStream(ServiceLoader.load(QuicheBinding.class)).sorted(Comparator.comparingInt(QuicheBinding::priority)).collect(Collectors.toList())); LOG.info("found quiche binding implementations: {}", TypeUtil.serviceStream(ServiceLoader.load(QuicheBinding.class)).sorted(Comparator.comparingInt(QuicheBinding::priority)).collect(Collectors.toList()));
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
{ {
List<QuicheBinding> bindings = TypeUtil.serviceStream(ServiceLoader.load(QuicheBinding.class)) List<QuicheBinding> bindings = TypeUtil.serviceStream(ServiceLoader.load(QuicheBinding.class))
.sorted(Comparator.comparingInt(QuicheBinding::priority)) .sorted(Comparator.comparingInt(QuicheBinding::priority))
.collect(Collectors.toList()); .collect(Collectors.toList());
LOG.debug("found Quiche binding implementations: {}", bindings); LOG.debug("found quiche binding implementations: {}", bindings);
} }
QUICHE_BINDING = TypeUtil.serviceStream(ServiceLoader.load(QuicheBinding.class)) QUICHE_BINDING = TypeUtil.serviceStream(ServiceLoader.load(QuicheBinding.class))
.filter(QuicheBinding::isUsable) .filter(QuicheBinding::isUsable)
.min(Comparator.comparingInt(QuicheBinding::priority)) .min(Comparator.comparingInt(QuicheBinding::priority))
.orElseThrow(() -> new IllegalStateException("no Quiche binding implementation found")); .orElseThrow(() -> new IllegalStateException("no quiche binding implementation found"));
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug("using Quiche binding implementation: {}", QUICHE_BINDING.getClass().getName()); LOG.debug("using quiche binding implementation: {}", QUICHE_BINDING.getClass().getName());
LOG.info("using Quiche binding implementation: {}", QUICHE_BINDING.getClass().getName()); LOG.info("using quiche binding implementation: {}", QUICHE_BINDING.getClass().getName());
} }
public static QuicheConnection connect(QuicheConfig quicheConfig, InetSocketAddress peer) throws IOException public static QuicheConnection connect(QuicheConfig quicheConfig, InetSocketAddress peer) throws IOException

View File

@ -7,11 +7,11 @@
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>quic-quiche-panama-jdk</artifactId> <artifactId>quic-quiche-foreign-incubator</artifactId>
<name>Jetty :: QUIC :: Quiche :: Panama Binding (jdk package)</name> <name>Jetty :: QUIC :: Quiche :: Foreign Binding (incubator)</name>
<properties> <properties>
<bundle-symbolic-name>${project.groupId}.quic-quiche-panama-jdk</bundle-symbolic-name> <bundle-symbolic-name>${project.groupId}.quic-quiche-foreign-incubator</bundle-symbolic-name>
</properties> </properties>
<build> <build>
@ -39,7 +39,7 @@
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<configuration> <configuration>
<argLine> <argLine>
@{argLine} ${jetty.surefire.argLine} --enable-native-access org.eclipse.jetty.quic.quiche.panama.jdk @{argLine} ${jetty.surefire.argLine} --enable-native-access org.eclipse.jetty.quic.quiche.foreign.incubator
</argLine> </argLine>
</configuration> </configuration>
</plugin> </plugin>

View File

@ -11,7 +11,7 @@
// ======================================================================== // ========================================================================
// //
module org.eclipse.jetty.quic.quiche.panama.jdk module org.eclipse.jetty.quic.quiche.foreign.incubator
{ {
requires jdk.incubator.foreign; requires jdk.incubator.foreign;
requires org.eclipse.jetty.quic.quiche; requires org.eclipse.jetty.quic.quiche;
@ -19,5 +19,5 @@ module org.eclipse.jetty.quic.quiche.panama.jdk
requires org.slf4j; requires org.slf4j;
provides org.eclipse.jetty.quic.quiche.QuicheBinding with provides org.eclipse.jetty.quic.quiche.QuicheBinding with
org.eclipse.jetty.quic.quiche.panama.jdk.PanamaJdkQuicheBinding; org.eclipse.jetty.quic.quiche.foreign.incubator.ForeignIncubatorQuicheBinding;
} }

View File

@ -11,7 +11,7 @@
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.quic.quiche.panama.jdk; package org.eclipse.jetty.quic.quiche.foreign.incubator;
import java.io.IOException; import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
@ -24,9 +24,9 @@ import org.eclipse.jetty.quic.quiche.QuicheConnection;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class PanamaJdkQuicheBinding implements QuicheBinding public class ForeignIncubatorQuicheBinding implements QuicheBinding
{ {
private static final Logger LOG = LoggerFactory.getLogger(PanamaJdkQuicheBinding.class); private static final Logger LOG = LoggerFactory.getLogger(ForeignIncubatorQuicheBinding.class);
@Override @Override
public boolean isUsable() public boolean isUsable()
@ -39,7 +39,7 @@ public class PanamaJdkQuicheBinding implements QuicheBinding
} }
catch (Throwable x) catch (Throwable x)
{ {
LOG.debug("Panama(jdk) quiche binding is not usable", x); LOG.debug("foreign incubator quiche binding is not usable", x);
return false; return false;
} }
} }
@ -53,25 +53,25 @@ public class PanamaJdkQuicheBinding implements QuicheBinding
@Override @Override
public byte[] fromPacket(ByteBuffer packet) public byte[] fromPacket(ByteBuffer packet)
{ {
return PanamaJdkQuicheConnection.fromPacket(packet); return ForeignIncubatorQuicheConnection.fromPacket(packet);
} }
@Override @Override
public QuicheConnection connect(QuicheConfig quicheConfig, InetSocketAddress peer, int connectionIdLength) throws IOException public QuicheConnection connect(QuicheConfig quicheConfig, InetSocketAddress peer, int connectionIdLength) throws IOException
{ {
return PanamaJdkQuicheConnection.connect(quicheConfig, peer, connectionIdLength); return ForeignIncubatorQuicheConnection.connect(quicheConfig, peer, connectionIdLength);
} }
@Override @Override
public boolean negotiate(QuicheConnection.TokenMinter tokenMinter, ByteBuffer packetRead, ByteBuffer packetToSend) throws IOException public boolean negotiate(QuicheConnection.TokenMinter tokenMinter, ByteBuffer packetRead, ByteBuffer packetToSend) throws IOException
{ {
return PanamaJdkQuicheConnection.negotiate(tokenMinter, packetRead, packetToSend); return ForeignIncubatorQuicheConnection.negotiate(tokenMinter, packetRead, packetToSend);
} }
@Override @Override
public QuicheConnection tryAccept(QuicheConfig quicheConfig, QuicheConnection.TokenValidator tokenValidator, ByteBuffer packetRead, SocketAddress peer) throws IOException public QuicheConnection tryAccept(QuicheConfig quicheConfig, QuicheConnection.TokenValidator tokenValidator, ByteBuffer packetRead, SocketAddress peer) throws IOException
{ {
return PanamaJdkQuicheConnection.tryAccept(quicheConfig, tokenValidator, packetRead, peer); return ForeignIncubatorQuicheConnection.tryAccept(quicheConfig, tokenValidator, packetRead, peer);
} }
@Override @Override

View File

@ -11,7 +11,7 @@
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.quic.quiche.panama.jdk; package org.eclipse.jetty.quic.quiche.foreign.incubator;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
@ -35,12 +35,9 @@ import org.eclipse.jetty.util.thread.AutoLock;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import static org.eclipse.jetty.quic.quiche.panama.jdk.quiche_h.C_FALSE; public class ForeignIncubatorQuicheConnection extends QuicheConnection
import static org.eclipse.jetty.quic.quiche.panama.jdk.quiche_h.C_TRUE;
public class PanamaJdkQuicheConnection extends QuicheConnection
{ {
private static final Logger LOG = LoggerFactory.getLogger(PanamaJdkQuicheConnection.class); private static final Logger LOG = LoggerFactory.getLogger(ForeignIncubatorQuicheConnection.class);
private static final SecureRandom SECURE_RANDOM = new SecureRandom(); private static final SecureRandom SECURE_RANDOM = new SecureRandom();
// Quiche does not allow concurrent calls with the same connection. // Quiche does not allow concurrent calls with the same connection.
@ -52,7 +49,7 @@ public class PanamaJdkQuicheConnection extends QuicheConnection
private MemorySegment recvInfo; private MemorySegment recvInfo;
private MemorySegment stats; private MemorySegment stats;
private PanamaJdkQuicheConnection(MemoryAddress quicheConn, MemoryAddress quicheConfig, ResourceScope scope) private ForeignIncubatorQuicheConnection(MemoryAddress quicheConn, MemoryAddress quicheConfig, ResourceScope scope)
{ {
this.quicheConn = quicheConn; this.quicheConn = quicheConn;
this.quicheConfig = quicheConfig; this.quicheConfig = quicheConfig;
@ -122,12 +119,12 @@ public class PanamaJdkQuicheConnection extends QuicheConnection
} }
} }
public static PanamaJdkQuicheConnection connect(QuicheConfig quicheConfig, InetSocketAddress peer) throws IOException public static ForeignIncubatorQuicheConnection connect(QuicheConfig quicheConfig, InetSocketAddress peer) throws IOException
{ {
return connect(quicheConfig, peer, quiche_h.QUICHE_MAX_CONN_ID_LEN); return connect(quicheConfig, peer, quiche_h.QUICHE_MAX_CONN_ID_LEN);
} }
public static PanamaJdkQuicheConnection connect(QuicheConfig quicheConfig, InetSocketAddress peer, int connectionIdLength) throws IOException public static ForeignIncubatorQuicheConnection connect(QuicheConfig quicheConfig, InetSocketAddress peer, int connectionIdLength) throws IOException
{ {
if (connectionIdLength > quiche_h.QUICHE_MAX_CONN_ID_LEN) if (connectionIdLength > quiche_h.QUICHE_MAX_CONN_ID_LEN)
throw new IOException("Connection ID length is too large: " + connectionIdLength + " > " + quiche_h.QUICHE_MAX_CONN_ID_LEN); throw new IOException("Connection ID length is too large: " + connectionIdLength + " > " + quiche_h.QUICHE_MAX_CONN_ID_LEN);
@ -140,7 +137,7 @@ public class PanamaJdkQuicheConnection extends QuicheConnection
MemorySegment s = sockaddr.convert(peer, scope); MemorySegment s = sockaddr.convert(peer, scope);
MemoryAddress quicheConn = quiche_h.quiche_connect(CLinker.toCString(peer.getHostName(), scope), scid, scid.byteSize(), s, s.byteSize(), libQuicheConfig); MemoryAddress quicheConn = quiche_h.quiche_connect(CLinker.toCString(peer.getHostName(), scope), scid, scid.byteSize(), s, s.byteSize(), libQuicheConfig);
return new PanamaJdkQuicheConnection(quicheConn, libQuicheConfig, scope); return new ForeignIncubatorQuicheConnection(quicheConn, libQuicheConfig, scope);
} }
private static MemoryAddress buildConfig(QuicheConfig config, ResourceScope scope) throws IOException private static MemoryAddress buildConfig(QuicheConfig config, ResourceScope scope) throws IOException
@ -151,7 +148,7 @@ public class PanamaJdkQuicheConnection extends QuicheConnection
Boolean verifyPeer = config.getVerifyPeer(); Boolean verifyPeer = config.getVerifyPeer();
if (verifyPeer != null) if (verifyPeer != null)
quiche_h.quiche_config_verify_peer(quicheConfig, verifyPeer ? C_TRUE : C_FALSE); quiche_h.quiche_config_verify_peer(quicheConfig, verifyPeer ? quiche_h.C_TRUE : quiche_h.C_FALSE);
String certChainPemPath = config.getCertChainPemPath(); String certChainPemPath = config.getCertChainPemPath();
if (certChainPemPath != null) if (certChainPemPath != null)
@ -211,7 +208,7 @@ public class PanamaJdkQuicheConnection extends QuicheConnection
Boolean disableActiveMigration = config.getDisableActiveMigration(); Boolean disableActiveMigration = config.getDisableActiveMigration();
if (disableActiveMigration != null) if (disableActiveMigration != null)
quiche_h.quiche_config_set_disable_active_migration(quicheConfig, disableActiveMigration ? C_TRUE : C_FALSE); quiche_h.quiche_config_set_disable_active_migration(quicheConfig, disableActiveMigration ? quiche_h.C_TRUE : quiche_h.C_FALSE);
return quicheConfig; return quicheConfig;
} }
@ -268,7 +265,7 @@ public class PanamaJdkQuicheConnection extends QuicheConnection
LOG.debug("dcid len: {}", dcid_len.asByteBuffer().order(ByteOrder.nativeOrder()).getLong()); LOG.debug("dcid len: {}", dcid_len.asByteBuffer().order(ByteOrder.nativeOrder()).getLong());
LOG.debug("token len: {}", token_len.asByteBuffer().order(ByteOrder.nativeOrder()).getLong()); LOG.debug("token len: {}", token_len.asByteBuffer().order(ByteOrder.nativeOrder()).getLong());
if (quiche_h.quiche_version_is_supported(version.asByteBuffer().order(ByteOrder.nativeOrder()).getInt()) == C_FALSE) if (quiche_h.quiche_version_is_supported(version.asByteBuffer().order(ByteOrder.nativeOrder()).getInt()) == quiche_h.C_FALSE)
{ {
LOG.debug("version negotiation"); LOG.debug("version negotiation");
@ -340,7 +337,7 @@ public class PanamaJdkQuicheConnection extends QuicheConnection
} }
} }
public static PanamaJdkQuicheConnection tryAccept(QuicheConfig quicheConfig, TokenValidator tokenValidator, ByteBuffer packetRead, SocketAddress peer) throws IOException public static ForeignIncubatorQuicheConnection tryAccept(QuicheConfig quicheConfig, TokenValidator tokenValidator, ByteBuffer packetRead, SocketAddress peer) throws IOException
{ {
ResourceScope scope = ResourceScope.newSharedScope(); ResourceScope scope = ResourceScope.newSharedScope();
@ -402,7 +399,7 @@ public class PanamaJdkQuicheConnection extends QuicheConnection
LOG.debug("dcid len: {}", dcid_len.asByteBuffer().order(ByteOrder.nativeOrder()).getLong()); LOG.debug("dcid len: {}", dcid_len.asByteBuffer().order(ByteOrder.nativeOrder()).getLong());
LOG.debug("token len: {}", token_len.asByteBuffer().order(ByteOrder.nativeOrder()).getLong()); LOG.debug("token len: {}", token_len.asByteBuffer().order(ByteOrder.nativeOrder()).getLong());
if (quiche_h.quiche_version_is_supported(version.asByteBuffer().order(ByteOrder.nativeOrder()).getInt()) == C_FALSE) if (quiche_h.quiche_version_is_supported(version.asByteBuffer().order(ByteOrder.nativeOrder()).getInt()) == quiche_h.C_FALSE)
{ {
LOG.debug("need version negotiation"); LOG.debug("need version negotiation");
scope.close(); scope.close();
@ -445,7 +442,7 @@ public class PanamaJdkQuicheConnection extends QuicheConnection
} }
LOG.debug("connection created"); LOG.debug("connection created");
PanamaJdkQuicheConnection quicheConnection = new PanamaJdkQuicheConnection(quicheConn, libQuicheConfig, scope); ForeignIncubatorQuicheConnection quicheConnection = new ForeignIncubatorQuicheConnection(quicheConn, libQuicheConfig, scope);
LOG.debug("accepted, immediately receiving the same packet - remaining in buffer: {}", packetRead.remaining()); LOG.debug("accepted, immediately receiving the same packet - remaining in buffer: {}", packetRead.remaining());
while (packetRead.hasRemaining()) while (packetRead.hasRemaining())
{ {
@ -472,7 +469,7 @@ public class PanamaJdkQuicheConnection extends QuicheConnection
try (ResourceScope scope = ResourceScope.newConfinedScope()) try (ResourceScope scope = ResourceScope.newConfinedScope())
{ {
MemorySegment streamIdSegment = MemorySegment.allocateNative(CLinker.C_LONG, scope); MemorySegment streamIdSegment = MemorySegment.allocateNative(CLinker.C_LONG, scope);
while (quiche_h.quiche_stream_iter_next(quiche_stream_iter, streamIdSegment.address()) != C_FALSE) while (quiche_h.quiche_stream_iter_next(quiche_stream_iter, streamIdSegment.address()) != quiche_h.C_FALSE)
{ {
long streamId = streamIdSegment.asByteBuffer().order(ByteOrder.nativeOrder()).getLong(); long streamId = streamIdSegment.asByteBuffer().order(ByteOrder.nativeOrder()).getLong();
result.add(streamId); result.add(streamId);
@ -563,7 +560,7 @@ public class PanamaJdkQuicheConnection extends QuicheConnection
{ {
if (quicheConn == null) if (quicheConn == null)
throw new IllegalStateException("connection was released"); throw new IllegalStateException("connection was released");
return quiche_h.quiche_conn_is_closed(quicheConn) != C_FALSE; return quiche_h.quiche_conn_is_closed(quicheConn) != quiche_h.C_FALSE;
} }
} }
@ -574,7 +571,7 @@ public class PanamaJdkQuicheConnection extends QuicheConnection
{ {
if (quicheConn == null) if (quicheConn == null)
throw new IllegalStateException("connection was released"); throw new IllegalStateException("connection was released");
return quiche_h.quiche_conn_is_established(quicheConn) != C_FALSE; return quiche_h.quiche_conn_is_established(quicheConn) != quiche_h.C_FALSE;
} }
} }
@ -639,7 +636,7 @@ public class PanamaJdkQuicheConnection extends QuicheConnection
int rc; int rc;
if (reason == null) if (reason == null)
{ {
rc = quiche_h.quiche_conn_close(quicheConn, C_TRUE, error, MemoryAddress.NULL, 0); rc = quiche_h.quiche_conn_close(quicheConn, quiche_h.C_TRUE, error, MemoryAddress.NULL, 0);
} }
else else
{ {
@ -650,7 +647,7 @@ public class PanamaJdkQuicheConnection extends QuicheConnection
reasonSegment.asByteBuffer().order(ByteOrder.nativeOrder()).put(reasonBytes); reasonSegment.asByteBuffer().order(ByteOrder.nativeOrder()).put(reasonBytes);
int length = reasonBytes.length; int length = reasonBytes.length;
MemoryAddress reasonAddress = reasonSegment.address(); MemoryAddress reasonAddress = reasonSegment.address();
rc = quiche_h.quiche_conn_close(quicheConn, C_TRUE, error, reasonAddress, length); rc = quiche_h.quiche_conn_close(quicheConn, quiche_h.C_TRUE, error, reasonAddress, length);
} }
} }
@ -693,7 +690,7 @@ public class PanamaJdkQuicheConnection extends QuicheConnection
{ {
if (quicheConn == null) if (quicheConn == null)
throw new IllegalStateException("connection was released"); throw new IllegalStateException("connection was released");
return quiche_h.quiche_conn_is_draining(quicheConn) != C_FALSE; return quiche_h.quiche_conn_is_draining(quicheConn) != quiche_h.C_FALSE;
} }
} }
@ -766,7 +763,7 @@ public class PanamaJdkQuicheConnection extends QuicheConnection
{ {
// If the ByteBuffer is direct, it can be used without any copy. // If the ByteBuffer is direct, it can be used without any copy.
MemorySegment bufferSegment = MemorySegment.ofByteBuffer(buffer); MemorySegment bufferSegment = MemorySegment.ofByteBuffer(buffer);
written = quiche_h.quiche_conn_stream_send(quicheConn, streamId, bufferSegment.address(), buffer.remaining(), last ? C_TRUE : C_FALSE); written = quiche_h.quiche_conn_stream_send(quicheConn, streamId, bufferSegment.address(), buffer.remaining(), last ? quiche_h.C_TRUE : quiche_h.C_FALSE);
} }
else else
{ {
@ -775,7 +772,7 @@ public class PanamaJdkQuicheConnection extends QuicheConnection
{ {
if (buffer.remaining() == 0) if (buffer.remaining() == 0)
{ {
written = quiche_h.quiche_conn_stream_send(quicheConn, streamId, MemoryAddress.NULL, 0, last ? C_TRUE : C_FALSE); written = quiche_h.quiche_conn_stream_send(quicheConn, streamId, MemoryAddress.NULL, 0, last ? quiche_h.C_TRUE : quiche_h.C_FALSE);
} }
else else
{ {
@ -783,7 +780,7 @@ public class PanamaJdkQuicheConnection extends QuicheConnection
int prevPosition = buffer.position(); int prevPosition = buffer.position();
bufferSegment.asByteBuffer().order(ByteOrder.nativeOrder()).put(buffer); bufferSegment.asByteBuffer().order(ByteOrder.nativeOrder()).put(buffer);
buffer.position(prevPosition); buffer.position(prevPosition);
written = quiche_h.quiche_conn_stream_send(quicheConn, streamId, bufferSegment.address(), buffer.remaining(), last ? C_TRUE : C_FALSE); written = quiche_h.quiche_conn_stream_send(quicheConn, streamId, bufferSegment.address(), buffer.remaining(), last ? quiche_h.C_TRUE : quiche_h.C_FALSE);
} }
} }
} }
@ -845,7 +842,7 @@ public class PanamaJdkQuicheConnection extends QuicheConnection
{ {
if (quicheConn == null) if (quicheConn == null)
throw new IllegalStateException("connection was released"); throw new IllegalStateException("connection was released");
return quiche_h.quiche_conn_stream_finished(quicheConn, streamId) != C_FALSE; return quiche_h.quiche_conn_stream_finished(quicheConn, streamId) != quiche_h.C_FALSE;
} }
} }
@ -862,7 +859,7 @@ public class PanamaJdkQuicheConnection extends QuicheConnection
MemorySegment error = MemorySegment.allocateNative(CLinker.C_LONG, scope); MemorySegment error = MemorySegment.allocateNative(CLinker.C_LONG, scope);
MemorySegment reason = MemorySegment.allocateNative(CLinker.C_POINTER, scope); MemorySegment reason = MemorySegment.allocateNative(CLinker.C_POINTER, scope);
MemorySegment reasonLength = MemorySegment.allocateNative(CLinker.C_LONG, scope); MemorySegment reasonLength = MemorySegment.allocateNative(CLinker.C_LONG, scope);
if (quiche_h.quiche_conn_peer_error(quicheConn, app.address(), error.address(), reason.address(), reasonLength.address()) != C_FALSE) if (quiche_h.quiche_conn_peer_error(quicheConn, app.address(), error.address(), reason.address(), reasonLength.address()) != quiche_h.C_FALSE)
{ {
long errorValue = error.asByteBuffer().order(ByteOrder.nativeOrder()).getLong(); long errorValue = error.asByteBuffer().order(ByteOrder.nativeOrder()).getLong();
long reasonLengthValue = reasonLength.asByteBuffer().order(ByteOrder.nativeOrder()).getLong(); long reasonLengthValue = reasonLength.asByteBuffer().order(ByteOrder.nativeOrder()).getLong();

View File

@ -11,7 +11,7 @@
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.quic.quiche.panama.jdk; package org.eclipse.jetty.quic.quiche.foreign.incubator;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;

View File

@ -11,7 +11,7 @@
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.quic.quiche.panama.jdk.linux; package org.eclipse.jetty.quic.quiche.foreign.incubator.linux;
import java.lang.invoke.VarHandle; import java.lang.invoke.VarHandle;
import java.net.Inet4Address; import java.net.Inet4Address;

View File

@ -11,7 +11,7 @@
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.quic.quiche.panama.jdk.macos; package org.eclipse.jetty.quic.quiche.foreign.incubator.macos;
import java.lang.invoke.VarHandle; import java.lang.invoke.VarHandle;
import java.net.Inet4Address; import java.net.Inet4Address;

View File

@ -11,7 +11,7 @@
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.quic.quiche.panama.jdk; package org.eclipse.jetty.quic.quiche.foreign.incubator;
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;
@ -27,7 +27,7 @@ import static jdk.incubator.foreign.CLinker.C_CHAR;
import static jdk.incubator.foreign.CLinker.C_INT; import static jdk.incubator.foreign.CLinker.C_INT;
import static jdk.incubator.foreign.CLinker.C_LONG; import static jdk.incubator.foreign.CLinker.C_LONG;
import static jdk.incubator.foreign.CLinker.C_POINTER; import static jdk.incubator.foreign.CLinker.C_POINTER;
import static org.eclipse.jetty.quic.quiche.panama.jdk.NativeHelper.downcallHandle; import static org.eclipse.jetty.quic.quiche.foreign.incubator.NativeHelper.downcallHandle;
public class quiche_h public class quiche_h
{ {

View File

@ -11,7 +11,7 @@
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.quic.quiche.panama.jdk; package org.eclipse.jetty.quic.quiche.foreign.incubator;
import java.lang.invoke.VarHandle; import java.lang.invoke.VarHandle;
import java.net.SocketAddress; import java.net.SocketAddress;

View File

@ -11,7 +11,7 @@
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.quic.quiche.panama.jdk; package org.eclipse.jetty.quic.quiche.foreign.incubator;
import jdk.incubator.foreign.MemoryLayout; import jdk.incubator.foreign.MemoryLayout;
import jdk.incubator.foreign.MemorySegment; import jdk.incubator.foreign.MemorySegment;

View File

@ -11,7 +11,7 @@
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.quic.quiche.panama.jdk; package org.eclipse.jetty.quic.quiche.foreign.incubator;
import java.lang.invoke.VarHandle; import java.lang.invoke.VarHandle;

View File

@ -11,29 +11,25 @@
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.quic.quiche.panama.jdk; package org.eclipse.jetty.quic.quiche.foreign.incubator;
import java.net.SocketAddress; import java.net.SocketAddress;
import jdk.incubator.foreign.MemorySegment; import jdk.incubator.foreign.MemorySegment;
import jdk.incubator.foreign.ResourceScope; import jdk.incubator.foreign.ResourceScope;
import org.eclipse.jetty.quic.quiche.panama.jdk.linux.sockaddr_linux; import org.eclipse.jetty.quic.quiche.foreign.incubator.linux.sockaddr_linux;
import org.eclipse.jetty.quic.quiche.panama.jdk.macos.sockaddr_macos; import org.eclipse.jetty.quic.quiche.foreign.incubator.macos.sockaddr_macos;
import org.eclipse.jetty.quic.quiche.panama.jdk.windows.sockaddr_windows; import org.eclipse.jetty.quic.quiche.foreign.incubator.windows.sockaddr_windows;
import static org.eclipse.jetty.quic.quiche.panama.jdk.NativeHelper.isLinux;
import static org.eclipse.jetty.quic.quiche.panama.jdk.NativeHelper.isMac;
import static org.eclipse.jetty.quic.quiche.panama.jdk.NativeHelper.isWindows;
public class sockaddr public class sockaddr
{ {
public static MemorySegment convert(SocketAddress socketAddress, ResourceScope scope) public static MemorySegment convert(SocketAddress socketAddress, ResourceScope scope)
{ {
if (isLinux()) if (NativeHelper.isLinux())
return sockaddr_linux.convert(socketAddress, scope); return sockaddr_linux.convert(socketAddress, scope);
if (isMac()) if (NativeHelper.isMac())
return sockaddr_macos.convert(socketAddress, scope); return sockaddr_macos.convert(socketAddress, scope);
if (isWindows()) if (NativeHelper.isWindows())
return sockaddr_windows.convert(socketAddress, scope); return sockaddr_windows.convert(socketAddress, scope);
throw new UnsupportedOperationException("Unsupported OS: " + System.getProperty("os.name")); throw new UnsupportedOperationException("Unsupported OS: " + System.getProperty("os.name"));
} }

View File

@ -11,7 +11,7 @@
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.quic.quiche.panama.jdk.windows; package org.eclipse.jetty.quic.quiche.foreign.incubator.windows;
import java.lang.invoke.VarHandle; import java.lang.invoke.VarHandle;
import java.net.Inet4Address; import java.net.Inet4Address;

View File

@ -0,0 +1 @@
org.eclipse.jetty.quic.quiche.foreign.incubator.ForeignIncubatorQuicheBinding

View File

@ -11,7 +11,7 @@
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.quic.quiche.panama.jdk; package org.eclipse.jetty.quic.quiche.foreign.incubator;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -40,14 +40,14 @@ import static org.hamcrest.core.Is.is;
public class LowLevelQuicheTest public class LowLevelQuicheTest
{ {
private final Collection<PanamaJdkQuicheConnection> connectionsToDisposeOf = new ArrayList<>(); private final Collection<ForeignIncubatorQuicheConnection> connectionsToDisposeOf = new ArrayList<>();
private InetSocketAddress clientSocketAddress; private InetSocketAddress clientSocketAddress;
private InetSocketAddress serverSocketAddress; private InetSocketAddress serverSocketAddress;
private QuicheConfig clientQuicheConfig; private QuicheConfig clientQuicheConfig;
private QuicheConfig serverQuicheConfig; private QuicheConfig serverQuicheConfig;
private PanamaJdkQuicheConnection.TokenMinter tokenMinter; private ForeignIncubatorQuicheConnection.TokenMinter tokenMinter;
private PanamaJdkQuicheConnection.TokenValidator tokenValidator; private ForeignIncubatorQuicheConnection.TokenValidator tokenValidator;
@BeforeEach @BeforeEach
protected void setUp() throws Exception protected void setUp() throws Exception
@ -91,7 +91,7 @@ public class LowLevelQuicheTest
@AfterEach @AfterEach
protected void tearDown() protected void tearDown()
{ {
connectionsToDisposeOf.forEach(PanamaJdkQuicheConnection::dispose); connectionsToDisposeOf.forEach(ForeignIncubatorQuicheConnection::dispose);
connectionsToDisposeOf.clear(); connectionsToDisposeOf.clear();
} }
@ -99,9 +99,9 @@ public class LowLevelQuicheTest
public void testFinishedAsSoonAsFinIsFed() throws Exception public void testFinishedAsSoonAsFinIsFed() throws Exception
{ {
// establish connection // establish connection
Map.Entry<PanamaJdkQuicheConnection, PanamaJdkQuicheConnection> entry = connectClientToServer(); Map.Entry<ForeignIncubatorQuicheConnection, ForeignIncubatorQuicheConnection> entry = connectClientToServer();
PanamaJdkQuicheConnection clientQuicheConnection = entry.getKey(); ForeignIncubatorQuicheConnection clientQuicheConnection = entry.getKey();
PanamaJdkQuicheConnection serverQuicheConnection = entry.getValue(); ForeignIncubatorQuicheConnection serverQuicheConnection = entry.getValue();
// client sends 16 bytes of payload over stream 0 // client sends 16 bytes of payload over stream 0
assertThat(clientQuicheConnection.feedClearBytesForStream(0, ByteBuffer.allocate(16) assertThat(clientQuicheConnection.feedClearBytesForStream(0, ByteBuffer.allocate(16)
@ -139,9 +139,9 @@ public class LowLevelQuicheTest
public void testNotFinishedAsLongAsStreamHasReadableBytes() throws Exception public void testNotFinishedAsLongAsStreamHasReadableBytes() throws Exception
{ {
// establish connection // establish connection
Map.Entry<PanamaJdkQuicheConnection, PanamaJdkQuicheConnection> entry = connectClientToServer(); Map.Entry<ForeignIncubatorQuicheConnection, ForeignIncubatorQuicheConnection> entry = connectClientToServer();
PanamaJdkQuicheConnection clientQuicheConnection = entry.getKey(); ForeignIncubatorQuicheConnection clientQuicheConnection = entry.getKey();
PanamaJdkQuicheConnection serverQuicheConnection = entry.getValue(); ForeignIncubatorQuicheConnection serverQuicheConnection = entry.getValue();
// client sends 16 bytes of payload over stream 0 and finish it // client sends 16 bytes of payload over stream 0 and finish it
assertThat(clientQuicheConnection.feedClearBytesForStream(0, ByteBuffer.allocate(16) assertThat(clientQuicheConnection.feedClearBytesForStream(0, ByteBuffer.allocate(16)
@ -175,18 +175,18 @@ public class LowLevelQuicheTest
clientQuicheConfig.setApplicationProtos(""); clientQuicheConfig.setApplicationProtos("");
// establish connection // establish connection
Map.Entry<PanamaJdkQuicheConnection, PanamaJdkQuicheConnection> entry = connectClientToServer(); Map.Entry<ForeignIncubatorQuicheConnection, ForeignIncubatorQuicheConnection> entry = connectClientToServer();
PanamaJdkQuicheConnection clientQuicheConnection = entry.getKey(); ForeignIncubatorQuicheConnection clientQuicheConnection = entry.getKey();
PanamaJdkQuicheConnection serverQuicheConnection = entry.getValue(); ForeignIncubatorQuicheConnection serverQuicheConnection = entry.getValue();
assertThat(clientQuicheConnection.getNegotiatedProtocol(), is("")); assertThat(clientQuicheConnection.getNegotiatedProtocol(), is(""));
assertThat(serverQuicheConnection.getNegotiatedProtocol(), is("")); assertThat(serverQuicheConnection.getNegotiatedProtocol(), is(""));
} }
private void drainServerToFeedClient(Map.Entry<PanamaJdkQuicheConnection, PanamaJdkQuicheConnection> entry, int expectedSize) throws IOException private void drainServerToFeedClient(Map.Entry<ForeignIncubatorQuicheConnection, ForeignIncubatorQuicheConnection> entry, int expectedSize) throws IOException
{ {
PanamaJdkQuicheConnection clientQuicheConnection = entry.getKey(); ForeignIncubatorQuicheConnection clientQuicheConnection = entry.getKey();
PanamaJdkQuicheConnection serverQuicheConnection = entry.getValue(); ForeignIncubatorQuicheConnection serverQuicheConnection = entry.getValue();
ByteBuffer buffer = ByteBuffer.allocate(quiche_h.QUICHE_MIN_CLIENT_INITIAL_LEN); ByteBuffer buffer = ByteBuffer.allocate(quiche_h.QUICHE_MIN_CLIENT_INITIAL_LEN);
int drained = serverQuicheConnection.drainCipherBytes(buffer); int drained = serverQuicheConnection.drainCipherBytes(buffer);
@ -196,10 +196,10 @@ public class LowLevelQuicheTest
assertThat(fed, is(expectedSize)); assertThat(fed, is(expectedSize));
} }
private void drainClientToFeedServer(Map.Entry<PanamaJdkQuicheConnection, PanamaJdkQuicheConnection> entry, int expectedSize) throws IOException private void drainClientToFeedServer(Map.Entry<ForeignIncubatorQuicheConnection, ForeignIncubatorQuicheConnection> entry, int expectedSize) throws IOException
{ {
PanamaJdkQuicheConnection clientQuicheConnection = entry.getKey(); ForeignIncubatorQuicheConnection clientQuicheConnection = entry.getKey();
PanamaJdkQuicheConnection serverQuicheConnection = entry.getValue(); ForeignIncubatorQuicheConnection serverQuicheConnection = entry.getValue();
ByteBuffer buffer = ByteBuffer.allocate(quiche_h.QUICHE_MIN_CLIENT_INITIAL_LEN); ByteBuffer buffer = ByteBuffer.allocate(quiche_h.QUICHE_MIN_CLIENT_INITIAL_LEN);
int drained = clientQuicheConnection.drainCipherBytes(buffer); int drained = clientQuicheConnection.drainCipherBytes(buffer);
@ -209,21 +209,21 @@ public class LowLevelQuicheTest
assertThat(fed, is(expectedSize)); assertThat(fed, is(expectedSize));
} }
private Map.Entry<PanamaJdkQuicheConnection, PanamaJdkQuicheConnection> connectClientToServer() throws IOException private Map.Entry<ForeignIncubatorQuicheConnection, ForeignIncubatorQuicheConnection> connectClientToServer() throws IOException
{ {
ByteBuffer buffer = ByteBuffer.allocate(quiche_h.QUICHE_MIN_CLIENT_INITIAL_LEN); ByteBuffer buffer = ByteBuffer.allocate(quiche_h.QUICHE_MIN_CLIENT_INITIAL_LEN);
ByteBuffer buffer2 = ByteBuffer.allocate(quiche_h.QUICHE_MIN_CLIENT_INITIAL_LEN); ByteBuffer buffer2 = ByteBuffer.allocate(quiche_h.QUICHE_MIN_CLIENT_INITIAL_LEN);
PanamaJdkQuicheConnection clientQuicheConnection = PanamaJdkQuicheConnection.connect(clientQuicheConfig, serverSocketAddress); ForeignIncubatorQuicheConnection clientQuicheConnection = ForeignIncubatorQuicheConnection.connect(clientQuicheConfig, serverSocketAddress);
connectionsToDisposeOf.add(clientQuicheConnection); connectionsToDisposeOf.add(clientQuicheConnection);
int drained = clientQuicheConnection.drainCipherBytes(buffer); int drained = clientQuicheConnection.drainCipherBytes(buffer);
assertThat(drained, is(1200)); assertThat(drained, is(1200));
buffer.flip(); buffer.flip();
PanamaJdkQuicheConnection serverQuicheConnection = PanamaJdkQuicheConnection.tryAccept(serverQuicheConfig, tokenValidator, buffer, clientSocketAddress); ForeignIncubatorQuicheConnection serverQuicheConnection = ForeignIncubatorQuicheConnection.tryAccept(serverQuicheConfig, tokenValidator, buffer, clientSocketAddress);
assertThat(serverQuicheConnection, is(nullValue())); assertThat(serverQuicheConnection, is(nullValue()));
boolean negotiated = PanamaJdkQuicheConnection.negotiate(tokenMinter, buffer, buffer2); boolean negotiated = ForeignIncubatorQuicheConnection.negotiate(tokenMinter, buffer, buffer2);
assertThat(negotiated, is(true)); assertThat(negotiated, is(true));
buffer2.flip(); buffer2.flip();
@ -235,7 +235,7 @@ public class LowLevelQuicheTest
assertThat(drained, is(1200)); assertThat(drained, is(1200));
buffer.flip(); buffer.flip();
serverQuicheConnection = PanamaJdkQuicheConnection.tryAccept(serverQuicheConfig, tokenValidator, buffer, clientSocketAddress); serverQuicheConnection = ForeignIncubatorQuicheConnection.tryAccept(serverQuicheConfig, tokenValidator, buffer, clientSocketAddress);
assertThat(serverQuicheConnection, is(not(nullValue()))); assertThat(serverQuicheConnection, is(not(nullValue())));
connectionsToDisposeOf.add(serverQuicheConnection); connectionsToDisposeOf.add(serverQuicheConnection);
@ -250,7 +250,7 @@ public class LowLevelQuicheTest
assertThat(serverQuicheConnection.isConnectionEstablished(), is(false)); assertThat(serverQuicheConnection.isConnectionEstablished(), is(false));
assertThat(clientQuicheConnection.isConnectionEstablished(), is(false)); assertThat(clientQuicheConnection.isConnectionEstablished(), is(false));
AbstractMap.SimpleImmutableEntry<PanamaJdkQuicheConnection, PanamaJdkQuicheConnection> entry = new AbstractMap.SimpleImmutableEntry<>(clientQuicheConnection, serverQuicheConnection); AbstractMap.SimpleImmutableEntry<ForeignIncubatorQuicheConnection, ForeignIncubatorQuicheConnection> entry = new AbstractMap.SimpleImmutableEntry<>(clientQuicheConnection, serverQuicheConnection);
int protosLen = 0; int protosLen = 0;
for (String proto : clientQuicheConfig.getApplicationProtos()) for (String proto : clientQuicheConfig.getApplicationProtos())

View File

@ -49,12 +49,12 @@ public interface LibQuiche extends Library
{ {
String quicheVersion = INSTANCE.quiche_version(); String quicheVersion = INSTANCE.quiche_version();
if (!EXPECTED_QUICHE_VERSION.equals(quicheVersion)) if (!EXPECTED_QUICHE_VERSION.equals(quicheVersion))
throw new IllegalStateException("Native Quiche library version [" + quicheVersion + "] does not match expected version [" + EXPECTED_QUICHE_VERSION + "]"); throw new IllegalStateException("native quiche library version [" + quicheVersion + "] does not match expected version [" + EXPECTED_QUICHE_VERSION + "]");
if (LIB_QUICHE_LOG.isDebugEnabled() && LOGGING_ENABLED.compareAndSet(false, true)) if (LIB_QUICHE_LOG.isDebugEnabled() && LOGGING_ENABLED.compareAndSet(false, true))
{ {
INSTANCE.quiche_enable_debug_logging(LIB_QUICHE_LOGGING_CALLBACK, null); INSTANCE.quiche_enable_debug_logging(LIB_QUICHE_LOGGING_CALLBACK, null);
LIB_QUICHE_LOG.debug("Quiche version {}", quicheVersion); LIB_QUICHE_LOG.debug("quiche version {}", quicheVersion);
} }
} }
} }

View File

@ -1 +0,0 @@
org.eclipse.jetty.quic.quiche.panama.jdk.PanamaJdkQuicheBinding