From b86395a778da3961773ef5825bfb739c363bd183 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Sat, 1 Jul 2023 20:26:27 +0200 Subject: [PATCH] Expose missing QUIC errors (#549) Motivation: We didnt expose all QUIC errors which lead to some IllegalArgumentException Modifications: Expose all errors Result: No more unexpected errors --- .../io/netty/incubator/codec/quic/QuicError.java | 5 ++++- .../io/netty/incubator/codec/quic/Quiche.java | 13 +++++++++++++ ...uicheNativeStaticallyReferencedJniMethods.java | 3 +++ codec-native-quic/src/main/c/netty_quic_quiche.c | 15 +++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/codec-classes-quic/src/main/java/io/netty/incubator/codec/quic/QuicError.java b/codec-classes-quic/src/main/java/io/netty/incubator/codec/quic/QuicError.java index ff563c253..05966b36b 100644 --- a/codec-classes-quic/src/main/java/io/netty/incubator/codec/quic/QuicError.java +++ b/codec-classes-quic/src/main/java/io/netty/incubator/codec/quic/QuicError.java @@ -37,7 +37,10 @@ public enum QuicError { FINAL_SIZE(Quiche.QUICHE_ERR_FINAL_SIZE, "QUICHE_ERR_FINAL_SIZE"), CONGESTION_CONTROL(Quiche.QUICHE_ERR_CONGESTION_CONTROL, "QUICHE_ERR_CONGESTION_CONTROL"), STREAM_RESET(Quiche.QUICHE_ERR_STREAM_RESET, "STREAM_RESET"), - STREAM_STOPPED(Quiche.QUICHE_ERR_STREAM_STOPPED, "STREAM_STOPPED"); + STREAM_STOPPED(Quiche.QUICHE_ERR_STREAM_STOPPED, "STREAM_STOPPED"), + ID_LIMIT(Quiche.QUICHE_ERR_ID_LIMIT, "ID_LIMIT"), + QUT_OF_IDENTIFIERS(Quiche.QUICHE_ERR_OUT_OF_IDENTIFIERS, "OUT_OF_IDENTIFIERS"), + KEY_UPDATE(Quiche.QUICHE_ERR_KEY_UPDATE, "KEY_UPDATE"); private static final IntObjectMap ERROR_MAP = new IntObjectHashMap<>(); diff --git a/codec-classes-quic/src/main/java/io/netty/incubator/codec/quic/Quiche.java b/codec-classes-quic/src/main/java/io/netty/incubator/codec/quic/Quiche.java index 85c42c1de..d136d02cc 100644 --- a/codec-classes-quic/src/main/java/io/netty/incubator/codec/quic/Quiche.java +++ b/codec-classes-quic/src/main/java/io/netty/incubator/codec/quic/Quiche.java @@ -259,6 +259,19 @@ private static void loadNativeLibrary() { static final int QUICHE_ERR_STREAM_STOPPED = QuicheNativeStaticallyReferencedJniMethods.quiche_err_stream_stopped(); + + // Too many identifiers were provided. + static final int QUICHE_ERR_ID_LIMIT = + QuicheNativeStaticallyReferencedJniMethods.quiche_err_id_limit(); + + // Not enough available identifiers. + static final int QUICHE_ERR_OUT_OF_IDENTIFIERS = + QuicheNativeStaticallyReferencedJniMethods.quiche_err_out_of_identifiers(); + + // Error in key update. + static final int QUICHE_ERR_KEY_UPDATE = + QuicheNativeStaticallyReferencedJniMethods.quiche_err_key_update(); + /** * See * QUICHE_CC_RENO. diff --git a/codec-classes-quic/src/main/java/io/netty/incubator/codec/quic/QuicheNativeStaticallyReferencedJniMethods.java b/codec-classes-quic/src/main/java/io/netty/incubator/codec/quic/QuicheNativeStaticallyReferencedJniMethods.java index f82b9b01a..2747c5019 100644 --- a/codec-classes-quic/src/main/java/io/netty/incubator/codec/quic/QuicheNativeStaticallyReferencedJniMethods.java +++ b/codec-classes-quic/src/main/java/io/netty/incubator/codec/quic/QuicheNativeStaticallyReferencedJniMethods.java @@ -38,6 +38,9 @@ final class QuicheNativeStaticallyReferencedJniMethods { static native int quiche_err_stream_stopped(); static native int quiche_err_stream_reset(); static native int quiche_err_congestion_control(); + static native int quiche_err_id_limit(); + static native int quiche_err_out_of_identifiers(); + static native int quiche_err_key_update(); static native int quiche_cc_reno(); static native int quiche_cc_cubic(); diff --git a/codec-native-quic/src/main/c/netty_quic_quiche.c b/codec-native-quic/src/main/c/netty_quic_quiche.c index 18f4da58d..031afab83 100644 --- a/codec-native-quic/src/main/c/netty_quic_quiche.c +++ b/codec-native-quic/src/main/c/netty_quic_quiche.c @@ -280,6 +280,18 @@ static jint netty_quiche_err_congestion_control(JNIEnv* env, jclass clazz) { return QUICHE_ERR_CONGESTION_CONTROL; } +static jint netty_quiche_err_id_limit(JNIEnv* env, jclass clazz) { + return QUICHE_ERR_ID_LIMIT; +} + +static jint netty_quiche_err_out_of_identifiers(JNIEnv* env, jclass clazz) { + return QUICHE_ERR_OUT_OF_IDENTIFIERS; +} + +static jint netty_quiche_err_key_update(JNIEnv* env, jclass clazz) { + return QUICHE_ERR_KEY_UPDATE; +} + static jint netty_quiche_cc_reno(JNIEnv* env, jclass clazz) { return QUICHE_CC_RENO; } @@ -801,6 +813,9 @@ static const JNINativeMethod statically_referenced_fixed_method_table[] = { { "quiche_err_stream_stopped", "()I", (void *) netty_quiche_err_stream_stopped }, { "quiche_err_stream_reset", "()I", (void *) netty_quiche_err_stream_reset }, { "quiche_err_congestion_control", "()I", (void *) netty_quiche_err_congestion_control }, + { "quiche_err_id_limit", "()I", (void *) netty_quiche_err_id_limit }, + { "quiche_err_out_of_identifiers", "()I", (void *) netty_quiche_err_out_of_identifiers }, + { "quiche_err_key_update", "()I", (void *) netty_quiche_err_key_update }, { "quiche_cc_reno", "()I", (void *) netty_quiche_cc_reno }, { "quiche_cc_cubic", "()I", (void *) netty_quiche_cc_cubic }, { "quiche_cc_bbr", "()I", (void *) netty_quiche_cc_bbr }