summaryrefslogtreecommitdiff
path: root/include/internal
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2022-12-01 16:37:47 +0000
committerHugo Landau <hlandau@openssl.org>2023-02-22 05:34:03 +0000
commit149a8e6c0a279b0dbbced72ffa6c5ed870a1bbc0 (patch)
tree668f6e0da5e938f52954f0dd3936706f9b57277d /include/internal
parentce3106baba7601bfaf1d1412221e18dec4878e18 (diff)
downloadopenssl-new-149a8e6c0a279b0dbbced72ffa6c5ed870a1bbc0.tar.gz
Enable QUIC test server to find out the termination reason
We enable querying of the termination reason which is useful for tests. Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20030)
Diffstat (limited to 'include/internal')
-rw-r--r--include/internal/quic_channel.h37
-rw-r--r--include/internal/quic_tserver.h7
2 files changed, 40 insertions, 4 deletions
diff --git a/include/internal/quic_channel.h b/include/internal/quic_channel.h
index a4039d8c02..4048bcd9c9 100644
--- a/include/internal/quic_channel.h
+++ b/include/internal/quic_channel.h
@@ -64,6 +64,34 @@ typedef struct quic_channel_args_st {
typedef struct quic_channel_st QUIC_CHANNEL;
+/* Represents the cause for a connection's termination. */
+typedef struct quic_terminate_cause_st {
+ /*
+ * If we are in a TERMINATING or TERMINATED state, this is the error code
+ * associated with the error. This field is valid iff we are in the
+ * TERMINATING or TERMINATED states.
+ */
+ uint64_t error_code;
+
+ /*
+ * If terminate_app is set and this is nonzero, this is the frame type which
+ * caused the connection to be terminated.
+ */
+ uint64_t frame_type;
+
+ /* Is this error code in the transport (0) or application (1) space? */
+ unsigned int app : 1;
+
+ /*
+ * If set, the cause of the termination is a received CONNECTION_CLOSE
+ * frame. Otherwise, we decided to terminate ourselves and sent a
+ * CONNECTION_CLOSE frame (regardless of whether the peer later also sends
+ * one).
+ */
+ unsigned int remote : 1;
+} QUIC_TERMINATE_CAUSE;
+
+
/*
* Create a new QUIC channel using the given arguments. The argument structure
* does not need to remain allocated. Returns NULL on failure.
@@ -158,9 +186,12 @@ QUIC_STREAM *ossl_quic_channel_get_stream_by_id(QUIC_CHANNEL *ch,
uint64_t stream_id);
/* Returns 1 if channel is terminating or terminated. */
-int ossl_quic_channel_is_term_any(const QUIC_CHANNEL *ch);
-int ossl_quic_channel_is_terminating(const QUIC_CHANNEL *ch);
-int ossl_quic_channel_is_terminated(const QUIC_CHANNEL *ch);
+int ossl_quic_channel_is_term_any(const QUIC_CHANNEL *ch,
+ QUIC_TERMINATE_CAUSE *cause);
+int ossl_quic_channel_is_terminating(const QUIC_CHANNEL *ch,
+ QUIC_TERMINATE_CAUSE *cause);
+int ossl_quic_channel_is_terminated(const QUIC_CHANNEL *ch,
+ QUIC_TERMINATE_CAUSE *cause);
int ossl_quic_channel_is_active(const QUIC_CHANNEL *ch);
int ossl_quic_channel_is_handshake_complete(const QUIC_CHANNEL *ch);
diff --git a/include/internal/quic_tserver.h b/include/internal/quic_tserver.h
index 0d564d8c21..cd26c81042 100644
--- a/include/internal/quic_tserver.h
+++ b/include/internal/quic_tserver.h
@@ -12,6 +12,7 @@
# include <openssl/ssl.h>
# include "internal/quic_stream.h"
+# include "internal/quic_channel.h"
# ifndef OPENSSL_NO_QUIC
@@ -54,8 +55,12 @@ int ossl_quic_tserver_tick(QUIC_TSERVER *srv);
int ossl_quic_tserver_is_connected(QUIC_TSERVER *srv);
/* Returns 1 if the server is in any terminating or terminated state */
-int ossl_quic_tserver_is_term_any(QUIC_TSERVER *srv);
+int ossl_quic_tserver_is_term_any(QUIC_TSERVER *srv,
+ QUIC_TERMINATE_CAUSE *cause);
+/* Returns 1 if the server is in a terminated state */
+int ossl_quic_tserver_is_terminated(QUIC_TSERVER *srv,
+ QUIC_TERMINATE_CAUSE *cause);
/*
* Attempts to read from stream 0. Writes the number of bytes read to
* *bytes_read and returns 1 on success. If no bytes are available, 0 is written