]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
QUIC DISPATCH/APL: Implement SSL_get_stream_id
authorHugo Landau <hlandau@openssl.org>
Tue, 18 Apr 2023 18:30:55 +0000 (19:30 +0100)
committerHugo Landau <hlandau@openssl.org>
Fri, 12 May 2023 13:47:11 +0000 (14:47 +0100)
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20765)

include/internal/quic_ssl.h
include/openssl/ssl.h.in
ssl/quic/quic_impl.c
ssl/ssl_lib.c

index 35873cd51ddc2342a87201aa0acfce8ed4a027cc..0ccb1c5526aabc4dde5613d837a9d696b324d2dc 100644 (file)
@@ -68,6 +68,7 @@ __owur int ossl_quic_conn_set_initial_peer_addr(SSL *s,
 __owur SSL *ossl_quic_conn_stream_new(SSL *s, uint64_t flags);
 __owur SSL *ossl_quic_get0_connection(SSL *s);
 __owur int ossl_quic_get_stream_type(SSL *s);
+__owur uint64_t ossl_quic_get_stream_id(SSL *s);
 
 /*
  * Used to override ossl_time_now() for debug purposes. Must be called before
index 25208ca29443a25e5223acec417f6d396b016f02..8d82bf6b5aae6846402020aa960a044c5e629ec2 100644 (file)
@@ -2275,6 +2275,8 @@ __owur int SSL_is_connection(SSL *s);
 #define SSL_STREAM_TYPE_BIDI        (SSL_STREAM_TYPE_READ | SSL_STREAM_TYPE_WRITE)
 __owur int SSL_get_stream_type(SSL *s);
 
+__owur uint64_t SSL_get_stream_id(SSL *s);
+
 #define SSL_STREAM_FLAG_UNI     (1U << 0)
 __owur SSL *SSL_new_stream(SSL *s, uint64_t flags);
 
index 2f97f7c6b58811eb510973d9bdbb5e1225afb3eb..6a28c00c75ec0572ab18a30060288eaec11a4ef6 100644 (file)
@@ -1867,6 +1867,20 @@ int ossl_quic_get_stream_type(SSL *s)
         return SSL_STREAM_TYPE_WRITE;
 }
 
+/*
+ * SSL_get_stream_id
+ * -----------------
+ */
+uint64_t ossl_quic_get_stream_id(SSL *s)
+{
+    QCTX ctx;
+
+    if (!expect_quic_with_stream(s, /*remote_init=*/-1, &ctx))
+        return UINT64_MAX;
+
+    return ctx.xso->stream->id;
+}
+
 /*
  * QUIC Front-End I/O API: SSL_CTX Management
  * ==========================================
index 5a226312da8bc5664de56c9ed811d9de708505ae..a7e3682291a3fae1dc17a230eba7e3fd7025c8e2 100644 (file)
@@ -7340,6 +7340,18 @@ int SSL_get_stream_type(SSL *s)
 #endif
 }
 
+uint64_t SSL_get_stream_id(SSL *s)
+{
+#ifndef OPENSSL_NO_QUIC
+    if (!IS_QUIC(s))
+        return UINT64_MAX;
+
+    return ossl_quic_get_stream_id(s);
+#else
+    return UINT64_MAX;
+#endif
+}
+
 int SSL_add_expected_rpk(SSL *s, EVP_PKEY *rpk)
 {
     unsigned char *data = NULL;