summaryrefslogtreecommitdiffstats
path: root/doc/designs
diff options
context:
space:
mode:
authorHugo Landau <hlandau@openssl.org>2023-08-09 17:46:34 +0100
committerHugo Landau <hlandau@openssl.org>2023-09-01 10:45:35 +0100
commitc276217e4bc9db08f0741882af837355f50c18ab (patch)
treec690a0a29ae0b0010b4af472668ddfa7857cd4ba /doc/designs
parent1ed2d7929a3f3fe86242116b0bc1366d36c3782d (diff)
QUIC DDD: ddd-02-conn-nonblocking-threads: Unplanned changes
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/21715)
Diffstat (limited to 'doc/designs')
-rw-r--r--doc/designs/ddd/ddd-02-conn-nonblocking-threads.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/doc/designs/ddd/ddd-02-conn-nonblocking-threads.c b/doc/designs/ddd/ddd-02-conn-nonblocking-threads.c
index 2f154138ed..892c36f1ce 100644
--- a/doc/designs/ddd/ddd-02-conn-nonblocking-threads.c
+++ b/doc/designs/ddd/ddd-02-conn-nonblocking-threads.c
@@ -33,7 +33,7 @@ SSL_CTX *create_ssl_ctx(void)
SSL_CTX *ctx;
#ifdef USE_QUIC
- ctx = SSL_CTX_new(QUIC_client_thread_method());
+ ctx = SSL_CTX_new(OSSL_QUIC_client_thread_method());
#else
ctx = SSL_CTX_new(TLS_client_method());
#endif
@@ -64,6 +64,9 @@ APP_CONN *new_conn(SSL_CTX *ctx, const char *hostname)
BIO *out, *buf;
SSL *ssl = NULL;
const char *bare_hostname;
+#ifdef USE_QUIC
+ static const unsigned char alpn[] = {5, 'd', 'u', 'm', 'm', 'y'};
+#endif
conn = calloc(1, sizeof(APP_CONN));
if (conn == NULL)
@@ -111,6 +114,15 @@ APP_CONN *new_conn(SSL_CTX *ctx, const char *hostname)
return NULL;
}
+#ifdef USE_QUIC
+ /* Configure ALPN, which is required for QUIC. */
+ if (SSL_set_alpn_protos(ssl, alpn, sizeof(alpn))) {
+ /* Note: SSL_set_alpn_protos returns 1 for failure. */
+ BIO_free_all(out);
+ return NULL;
+ }
+#endif
+
/* Make the BIO nonblocking. */
BIO_set_nbio(out, 1);
@@ -175,7 +187,12 @@ int rx(APP_CONN *conn, void *buf, int buf_len)
int get_conn_fd(APP_CONN *conn)
{
#ifdef USE_QUIC
- return BIO_get_poll_fd(conn->ssl_bio, NULL);
+ BIO_POLL_DESCRIPTOR d;
+
+ if (!BIO_get_rpoll_descriptor(conn->ssl_bio, &d))
+ return -1;
+
+ return d.value.fd;
#else
return BIO_get_fd(conn->ssl_bio, NULL);
#endif
@@ -197,7 +214,9 @@ int get_conn_fd(APP_CONN *conn)
int get_conn_pending_tx(APP_CONN *conn)
{
#ifdef USE_QUIC
- return POLLIN | POLLOUT | POLLERR;
+ return (SSL_net_read_desired(conn->ssl) ? POLLIN : 0)
+ | (SSL_net_write_desired(conn->ssl) ? POLLOUT : 0)
+ | POLLERR;
#else
return (conn->tx_need_rx ? POLLIN : 0) | POLLOUT | POLLERR;
#endif
@@ -205,7 +224,11 @@ int get_conn_pending_tx(APP_CONN *conn)
int get_conn_pending_rx(APP_CONN *conn)
{
+#ifdef USE_QUIC
+ return get_conn_pending_tx(conn);
+#else
return (conn->rx_need_tx ? POLLOUT : 0) | POLLIN | POLLERR;
+#endif
}
/*