From 842bbe7fcb965eb600d52512d8d062803b64d010 Mon Sep 17 00:00:00 2001 From: Ludovic Orban Date: Mon, 25 Sep 2023 17:11:56 +0200 Subject: [PATCH] #10557 upgrade quiche to version 0.18.0 (#10570) Signed-off-by: Ludovic Orban --- .../org/eclipse/jetty/quic/quiche/Quiche.java | 23 +++++++++++--- .../quiche/foreign/incubator/quiche_h.java | 2 +- .../jetty/quic/quiche/jna/LibQuiche.java | 31 ++++++++++++++++++- .../jetty/quic/quiche/jna/int64_t.java | 28 +++++++++++++++++ pom.xml | 2 +- 5 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 jetty-quic/quic-quiche/quic-quiche-jna/src/main/java/org/eclipse/jetty/quic/quiche/jna/int64_t.java diff --git a/jetty-quic/quic-quiche/quic-quiche-common/src/main/java/org/eclipse/jetty/quic/quiche/Quiche.java b/jetty-quic/quic-quiche/quic-quiche-common/src/main/java/org/eclipse/jetty/quic/quiche/Quiche.java index c7cf2c4c64d..7b90dafc140 100644 --- a/jetty-quic/quic-quiche/quic-quiche-common/src/main/java/org/eclipse/jetty/quic/quiche/Quiche.java +++ b/jetty-quic/quic-quiche/quic-quiche-common/src/main/java/org/eclipse/jetty/quic/quiche/Quiche.java @@ -70,17 +70,26 @@ public interface Quiche // The peer violated the local stream limits. QUICHE_ERR_STREAM_LIMIT = -12, + // The received data exceeds the stream's final size. + QUICHE_ERR_FINAL_SIZE = -13, + + // Error in congestion control. + QUICHE_ERR_CONGESTION_CONTROL = -14, + // The specified stream was stopped by the peer. QUICHE_ERR_STREAM_STOPPED = -15, // The specified stream was reset by the peer. QUICHE_ERR_STREAM_RESET = -16, - // The received data exceeds the stream's final size. - QUICHE_ERR_FINAL_SIZE = -13, + // Too many identifiers were provided. + QUICHE_ERR_ID_LIMIT = -17, - // Error in congestion control. - QUICHE_ERR_CONGESTION_CONTROL = -14; + // Not enough available identifiers. + QUICHE_ERR_OUT_OF_IDENTIFIERS = -18, + + // Error in key update. + QUICHE_ERR_KEY_UPDATE = -19; static String errToString(long err) { @@ -116,6 +125,12 @@ public interface Quiche return "QUICHE_ERR_STREAM_STOPPED"; if (err == QUICHE_ERR_STREAM_RESET) return "QUICHE_ERR_STREAM_RESET"; + if (err == QUICHE_ERR_ID_LIMIT) + return "QUICHE_ERR_ID_LIMIT"; + if (err == QUICHE_ERR_OUT_OF_IDENTIFIERS) + return "QUICHE_ERR_OUT_OF_IDENTIFIERS"; + if (err == QUICHE_ERR_KEY_UPDATE) + return "QUICHE_ERR_KEY_UPDATE"; return "?? " + err; } } diff --git a/jetty-quic/quic-quiche/quic-quiche-foreign-incubator/src/main/java/org/eclipse/jetty/quic/quiche/foreign/incubator/quiche_h.java b/jetty-quic/quic-quiche/quic-quiche-foreign-incubator/src/main/java/org/eclipse/jetty/quic/quiche/foreign/incubator/quiche_h.java index 4e89ae1a303..9994b5bcfe6 100644 --- a/jetty-quic/quic-quiche/quic-quiche-foreign-incubator/src/main/java/org/eclipse/jetty/quic/quiche/foreign/incubator/quiche_h.java +++ b/jetty-quic/quic-quiche/quic-quiche-foreign-incubator/src/main/java/org/eclipse/jetty/quic/quiche/foreign/incubator/quiche_h.java @@ -33,7 +33,7 @@ public class quiche_h { // This interface is a translation of the quiche.h header of a specific version. // It needs to be reviewed each time the native lib version changes. - private static final String EXPECTED_QUICHE_VERSION = "0.16.0"; + private static final String EXPECTED_QUICHE_VERSION = "0.18.0"; public static final byte C_FALSE = 0; public static final byte C_TRUE = 1; diff --git a/jetty-quic/quic-quiche/quic-quiche-jna/src/main/java/org/eclipse/jetty/quic/quiche/jna/LibQuiche.java b/jetty-quic/quic-quiche/quic-quiche-jna/src/main/java/org/eclipse/jetty/quic/quiche/jna/LibQuiche.java index 1cb5e5530b4..b1ff0518922 100644 --- a/jetty-quic/quic-quiche/quic-quiche-jna/src/main/java/org/eclipse/jetty/quic/quiche/jna/LibQuiche.java +++ b/jetty-quic/quic-quiche/quic-quiche-jna/src/main/java/org/eclipse/jetty/quic/quiche/jna/LibQuiche.java @@ -31,7 +31,7 @@ public interface LibQuiche extends Library { // This interface is a translation of the quiche.h header of a specific version. // It needs to be reviewed each time the native lib version changes. - String EXPECTED_QUICHE_VERSION = "0.16.0"; + String EXPECTED_QUICHE_VERSION = "0.18.0"; // The charset used to convert java.lang.String to char * and vice versa. Charset CHARSET = StandardCharsets.UTF_8; @@ -373,6 +373,17 @@ public interface LibQuiche extends Library // field of `quiche_stats`). int quiche_conn_path_stats(quiche_conn conn, size_t idx, quiche_path_stats out); + // Returns whether or not this is a server-side connection. + boolean quiche_conn_is_server(quiche_conn conn); + + // Schedule an ack-eliciting packet on the active path. + ssize_t quiche_conn_send_ack_eliciting(quiche_conn conn); + + // Schedule an ack-eliciting packet on the specified path. + ssize_t quiche_conn_send_ack_eliciting_on_path(quiche_conn conn, + sockaddr local, size_t local_len, + sockaddr peer, size_t peer_len); + @Structure.FieldOrder({"from", "from_len", "to", "to_len", "at"}) class quiche_send_info extends Structure { @@ -457,6 +468,7 @@ public interface LibQuiche extends Library public byte dummy; } + // The side of the stream to be shut down. interface quiche_shutdown { int QUICHE_SHUTDOWN_READ = 0, @@ -471,8 +483,25 @@ public interface LibQuiche extends Library int quiche_conn_stream_shutdown(quiche_conn conn, uint64_t stream_id, int /*quiche_shutdown*/ direction, uint64_t err); + // Returns the stream's send capacity in bytes. ssize_t quiche_conn_stream_capacity(quiche_conn conn, uint64_t stream_id); + // Returns true if the stream has data that can be read. + boolean quiche_conn_stream_readable(quiche_conn conn, uint64_t stream_id); + + // Returns the next stream that has data to read, or -1 if no such stream is + // available. + int64_t quiche_conn_stream_readable_next(quiche_conn conn); + + // Returns true if the stream has enough send capacity. + // + // On error a value lower than 0 is returned. + int quiche_conn_stream_writable(quiche_conn conn, uint64_t stream_id, size_t len); + + // Returns the next stream that can be written to, or -1 if no such stream is + // available. + int64_t quiche_conn_stream_writable_next(quiche_conn conn); + // Returns true if all the data has been read from the specified stream. boolean quiche_conn_stream_finished(quiche_conn conn, uint64_t stream_id); diff --git a/jetty-quic/quic-quiche/quic-quiche-jna/src/main/java/org/eclipse/jetty/quic/quiche/jna/int64_t.java b/jetty-quic/quic-quiche/quic-quiche-jna/src/main/java/org/eclipse/jetty/quic/quiche/jna/int64_t.java new file mode 100644 index 00000000000..6cf3048d9fa --- /dev/null +++ b/jetty-quic/quic-quiche/quic-quiche-jna/src/main/java/org/eclipse/jetty/quic/quiche/jna/int64_t.java @@ -0,0 +1,28 @@ +// +// ======================================================================== +// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +package org.eclipse.jetty.quic.quiche.jna; + +import com.sun.jna.IntegerType; + +public class int64_t extends IntegerType +{ + public int64_t() + { + this(0); + } + public int64_t(long v) + { + super(8, v, false); + } +} diff --git a/pom.xml b/pom.xml index 15003457185..f16fca2c9af 100644 --- a/pom.xml +++ b/pom.xml @@ -84,7 +84,7 @@ 3.5.0.Final 1.1 1.0.7 - 0.16.0 + 0.18.0 4.0.6 1.2 6.0