diff options
author | Hugo Landau <hlandau@openssl.org> | 2023-04-18 19:30:55 +0100 |
---|---|---|
committer | Hugo Landau <hlandau@openssl.org> | 2023-05-12 14:47:11 +0100 |
commit | 1bca3f1b2d139c2306fd65d23583e4d16bdc11f9 (patch) | |
tree | f05348068242a8440696a39863b9d5822035cd7f /ssl | |
parent | e1dee2e37971e068d6aff25dbfc92ef4db5adbd9 (diff) | |
download | openssl-new-1bca3f1b2d139c2306fd65d23583e4d16bdc11f9.tar.gz |
QUIC DISPATCH/APL: Implement SSL_get_stream_type
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20765)
Diffstat (limited to 'ssl')
-rw-r--r-- | ssl/quic/quic_impl.c | 32 | ||||
-rw-r--r-- | ssl/ssl_lib.c | 12 |
2 files changed, 44 insertions, 0 deletions
diff --git a/ssl/quic/quic_impl.c b/ssl/quic/quic_impl.c index 3ed03b1c86..2f97f7c6b5 100644 --- a/ssl/quic/quic_impl.c +++ b/ssl/quic/quic_impl.c @@ -1836,6 +1836,38 @@ SSL *ossl_quic_get0_connection(SSL *s) } /* + * SSL_get_stream_type + * ------------------- + */ +int ossl_quic_get_stream_type(SSL *s) +{ + QCTX ctx; + + if (!expect_quic(s, &ctx)) + return SSL_STREAM_TYPE_NONE; + + if (ctx.xso == NULL) { + /* + * If we are deferring XSO creation, assume single stream mode and + * default to BIDI, as the deferred XSO which will be created will be + * bidirectional. + */ + if (!ctx.qc->default_xso_created) + return SSL_STREAM_TYPE_BIDI; + else + return SSL_STREAM_TYPE_NONE; + } + + if (ossl_quic_stream_is_bidi(ctx.xso->stream)) + return SSL_STREAM_TYPE_BIDI; + + if (ossl_quic_stream_is_server_init(ctx.xso->stream) != ctx.qc->as_server) + return SSL_STREAM_TYPE_READ; + else + return SSL_STREAM_TYPE_WRITE; +} + +/* * QUIC Front-End I/O API: SSL_CTX Management * ========================================== */ diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 29d16107ae..5a226312da 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -7328,6 +7328,18 @@ int SSL_is_connection(SSL *s) return SSL_get0_connection(s) == s; } +int SSL_get_stream_type(SSL *s) +{ +#ifndef OPENSSL_NO_QUIC + if (!IS_QUIC(s)) + return SSL_STREAM_TYPE_BIDI; + + return ossl_quic_get_stream_type(s); +#else + return SSL_STREAM_TYPE_BIDI; +#endif +} + int SSL_add_expected_rpk(SSL *s, EVP_PKEY *rpk) { unsigned char *data = NULL; |