From: Hugo Landau Date: Thu, 11 Jan 2024 09:33:36 +0000 (+0000) Subject: QUIC APL: Add skeleton listener API methods X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5865ec85880aae8f3f1853202d11ac3f30e0c9c5;p=thirdparty%2Fopenssl.git QUIC APL: Add skeleton listener API methods Reviewed-by: Matt Caswell Reviewed-by: Neil Horman (Merged from https://github.com/openssl/openssl/pull/23334) --- diff --git a/include/internal/quic_ssl.h b/include/internal/quic_ssl.h index 4b8eb83d6f1..f0dcf59ba0b 100644 --- a/include/internal/quic_ssl.h +++ b/include/internal/quic_ssl.h @@ -77,6 +77,7 @@ __owur int ossl_quic_conn_set_initial_peer_addr(SSL *s, const BIO_ADDR *peer_addr); __owur SSL *ossl_quic_conn_stream_new(SSL *s, uint64_t flags); __owur SSL *ossl_quic_get0_connection(SSL *s); +__owur SSL *ossl_quic_get0_listener(SSL *s); __owur int ossl_quic_get_stream_type(SSL *s); __owur uint64_t ossl_quic_get_stream_id(SSL *s); __owur int ossl_quic_is_stream_local(SSL *s); @@ -91,6 +92,9 @@ __owur int ossl_quic_get_value_uint(SSL *s, uint32_t class_, uint32_t id, uint64_t *value); __owur int ossl_quic_set_value_uint(SSL *s, uint32_t class_, uint32_t id, uint64_t value); +__owur SSL *ossl_quic_accept_connection(SSL *ssl, uint64_t flags); +__owur size_t ossl_quic_get_accept_connection_queue_len(SSL *ssl); +__owur int ossl_quic_listen(SSL *ssl); __owur int ossl_quic_stream_reset(SSL *ssl, const SSL_STREAM_RESET_ARGS *args, diff --git a/include/openssl/ssl.h.in b/include/openssl/ssl.h.in index 575c5b53fc2..707ffa6df02 100644 --- a/include/openssl/ssl.h.in +++ b/include/openssl/ssl.h.in @@ -2292,7 +2292,12 @@ __owur int SSL_set1_initial_peer_addr(SSL *s, const BIO_ADDR *peer_addr); __owur SSL *SSL_get0_connection(SSL *s); __owur int SSL_is_connection(SSL *s); +__owur int SSL_is_listener(SSL *ssl); +__owur SSL *SSL_get0_listener(SSL *s); __owur SSL *SSL_new_listener(SSL_CTX *ctx, uint64_t flags); +__owur SSL *SSL_accept_connection(SSL *ssl, uint64_t flags); +__owur size_t SSL_get_accept_connection_queue_len(SSL *ssl); +__owur int SSL_listen(SSL *ssl); #define SSL_STREAM_TYPE_NONE 0 #define SSL_STREAM_TYPE_READ (1U << 0) diff --git a/ssl/quic/quic_impl.c b/ssl/quic/quic_impl.c index f0e18bc7500..3f305e8bf71 100644 --- a/ssl/quic/quic_impl.c +++ b/ssl/quic/quic_impl.c @@ -3003,6 +3003,20 @@ SSL *ossl_quic_get0_connection(SSL *s) return &ctx.qc->obj.ssl; } +/* + * SSL_get0_listener + * ----------------- + */ +SSL *ossl_quic_get0_listener(SSL *s) +{ + QCTX ctx; + + if (!expect_quic(s, &ctx)) + return NULL; + + return NULL; // XXX TODO +} + /* * SSL_get_stream_type * ------------------- @@ -3992,6 +4006,21 @@ err: return NULL; } +SSL *ossl_quic_accept_connection(SSL *ssl, uint64_t flags) +{ + return NULL; // TODO XXX +} + +size_t ossl_quic_get_accept_connection_queue_len(SSL *ssl) +{ + return 0; // TODO XXX +} + +int ossl_quic_listen(SSL *ssl) +{ + return 0; // TODO XXX +} + /* * QUIC Front-End I/O API: SSL_CTX Management * ========================================== diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 60ea517235f..fabfba2e83f 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -7534,6 +7534,23 @@ int SSL_is_connection(SSL *s) return SSL_get0_connection(s) == s; } +SSL *SSL_get0_listener(SSL *s) +{ +#ifndef OPENSSL_NO_QUIC + if (!IS_QUIC(s)) + return s; + + return ossl_quic_get0_listener(s); +#else + return s; +#endif +} + +int SSL_is_listener(SSL *s) +{ + return SSL_get0_listener(s) == s; +} + int SSL_get_stream_type(SSL *s) { #ifndef OPENSSL_NO_QUIC @@ -7729,6 +7746,42 @@ SSL *SSL_new_listener(SSL_CTX *ctx, uint64_t flags) #endif } +SSL *SSL_accept_connection(SSL *ssl, uint64_t flags) +{ +#ifndef OPENSSL_NO_QUIC + if (!IS_QUIC(ssl)) + return NULL; + + return ossl_quic_accept_connection(ssl, flags); +#else + return NULL; +#endif +} + +size_t SSL_get_accept_connection_queue_len(SSL *ssl) +{ +#ifndef OPENSSL_NO_QUIC + if (!IS_QUIC(ssl)) + return 0; + + return ossl_quic_get_accept_connection_queue_len(ssl); +#else + return 0; +#endif +} + +int SSL_listen(SSL *ssl) +{ +#ifndef OPENSSL_NO_QUIC + if (!IS_QUIC(ssl)) + return 0; + + return ossl_quic_listen(ssl); +#else + return 0; +#endif +} + int SSL_add_expected_rpk(SSL *s, EVP_PKEY *rpk) { unsigned char *data = NULL;