QUIC: Add polling API
authorHugo Landau <hlandau@openssl.org>
Wed, 31 Jan 2024 12:35:15 +0000 (12:35 +0000)
committerHugo Landau <hlandau@openssl.org>
Sat, 10 Feb 2024 11:37:14 +0000 (11:37 +0000)
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23495)

crypto/err/openssl.txt
include/openssl/ssl.h.in
include/openssl/sslerr.h
ssl/ssl_err.c
util/libssl.num

index 8476c48f00446fd2a8c6a3692fceaa10e1823f0a..74e44088d09e22a96e07eff251592bcd18639d15 100644 (file)
@@ -1507,6 +1507,7 @@ SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE:199:peer did not return a certificate
 SSL_R_PEM_NAME_BAD_PREFIX:391:pem name bad prefix
 SSL_R_PEM_NAME_TOO_SHORT:392:pem name too short
 SSL_R_PIPELINE_FAILURE:406:pipeline failure
+SSL_R_POLL_REQUEST_NOT_SUPPORTED:413:poll request not supported
 SSL_R_POST_HANDSHAKE_AUTH_ENCODING_ERR:278:post handshake auth encoding err
 SSL_R_PRIVATE_KEY_MISMATCH:288:private key mismatch
 SSL_R_PROTOCOL_IS_SHUTDOWN:207:protocol is shutdown
index 6b54658b4f55a6e087325ec0278afe4a9be67f3c..8e98e6acf29fd0a61e2f650daf1c55cad5e9749f 100644 (file)
@@ -2407,6 +2407,58 @@ int SSL_set_value_uint(SSL *s, uint32_t class_, uint32_t id, uint64_t v);
     SSL_get_generic_value_uint((ssl), SSL_VALUE_QUIC_STREAM_UNI_REMOTE_AVAIL, \
                                (value))
 
+# define SSL_POLL_EVENT_NONE        0
+
+# define SSL_POLL_EVENT_F           (1U <<  0) /* F   (Failure) */
+# define SSL_POLL_EVENT_EL          (1U <<  1) /* EL  (Exception on Listener) */
+# define SSL_POLL_EVENT_EC          (1U <<  2) /* EC  (Exception on Conn) */
+# define SSL_POLL_EVENT_ECD         (1U <<  3) /* ECD (Exception on Conn Drained) */
+# define SSL_POLL_EVENT_ER          (1U <<  4) /* ER  (Exception on Read) */
+# define SSL_POLL_EVENT_EW          (1U <<  5) /* EW  (Exception on Write) */
+# define SSL_POLL_EVENT_R           (1U <<  6) /* R   (Readable) */
+# define SSL_POLL_EVENT_W           (1U <<  7) /* W   (Writable) */
+# define SSL_POLL_EVENT_IC          (1U <<  8) /* IC  (Incoming Connection) */
+# define SSL_POLL_EVENT_ISB         (1U <<  9) /* ISB (Incoming Stream: Bidi) */
+# define SSL_POLL_EVENT_ISU         (1U << 10) /* ISU (Incoming Stream: Uni) */
+# define SSL_POLL_EVENT_OSB         (1U << 11) /* OSB (Outgoing Stream: Bidi) */
+# define SSL_POLL_EVENT_OSU         (1U << 12) /* OSU (Outgoing Stream: Uni) */
+
+# define SSL_POLL_EVENT_RW          (SSL_POLL_EVENT_R | SSL_POLL_EVENT_W)
+# define SSL_POLL_EVENT_RE          (SSL_POLL_EVENT_R | SSL_POLL_EVENT_ER)
+# define SSL_POLL_EVENT_WE          (SSL_POLL_EVENT_W | SSL_POLL_EVENT_EW)
+# define SSL_POLL_EVENT_RWE         (SSL_POLL_EVENT_RE | SSL_POLL_EVENT_WE)
+# define SSL_POLL_EVENT_E           (SSL_POLL_EVENT_EL | SSL_POLL_EVENT_EC \
+                                     | SSL_POLL_EVENT_ER | SSL_POLL_EVENT_EW)
+# define SSL_POLL_EVENT_IS          (SSL_POLL_EVENT_ISB | SSL_POLL_EVENT_ISU)
+# define SSL_POLL_EVENT_ISE         (SSL_POLL_EVENT_IS | SSL_POLL_EVENT_EC)
+# define SSL_POLL_EVENT_I           (SSL_POLL_EVENT_IS | SSL_POLL_EVENT_IC)
+# define SSL_POLL_EVENT_OS          (SSL_POLL_EVENT_OSB | SSL_POLL_EVENT_OSU)
+# define SSL_POLL_EVENT_OSE         (SSL_POLL_EVENT_OS | SSL_POLL_EVENT_EC)
+
+typedef struct ssl_poll_item_st {
+    BIO_POLL_DESCRIPTOR desc;
+    uint64_t            events, revents;
+} SSL_POLL_ITEM;
+
+# define SSL_POLL_FLAG_NO_HANDLE_EVENTS  (1U << 0)
+
+__owur int SSL_poll(SSL_POLL_ITEM *items,
+                    size_t num_items,
+                    size_t stride,
+                    const struct timeval *timeout,
+                    uint64_t flags,
+                    size_t *result_count);
+
+static ossl_inline ossl_unused BIO_POLL_DESCRIPTOR
+SSL_as_poll_descriptor(SSL *s)
+{
+    BIO_POLL_DESCRIPTOR d;
+
+    d.type      = BIO_POLL_DESCRIPTOR_TYPE_SSL;
+    d.value.ssl = s;
+    return d;
+}
+
 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
 #  define SSL_cache_hit(s) SSL_session_reused(s)
 # endif
index bd90340058803d803d9b4645ebc757f69f5e3ebf..505bafacb2ad5582e9d2be6bc63adc08ffa5a9ba 100644 (file)
 # define SSL_R_PEM_NAME_BAD_PREFIX                        391
 # define SSL_R_PEM_NAME_TOO_SHORT                         392
 # define SSL_R_PIPELINE_FAILURE                           406
+# define SSL_R_POLL_REQUEST_NOT_SUPPORTED                 413
 # define SSL_R_POST_HANDSHAKE_AUTH_ENCODING_ERR           278
 # define SSL_R_PRIVATE_KEY_MISMATCH                       288
 # define SSL_R_PROTOCOL_IS_SHUTDOWN                       207
index a1ce627456a162b6b549d099a549220e3177ab58..a1da9fde3946cd1334015d08e32690559757d17d 100644 (file)
@@ -351,6 +351,8 @@ static const ERR_STRING_DATA SSL_str_reasons[] = {
     "pem name bad prefix"},
     {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_PEM_NAME_TOO_SHORT), "pem name too short"},
     {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_PIPELINE_FAILURE), "pipeline failure"},
+    {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_POLL_REQUEST_NOT_SUPPORTED),
+    "poll request not supported"},
     {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_POST_HANDSHAKE_AUTH_ENCODING_ERR),
     "post handshake auth encoding err"},
     {ERR_PACK(ERR_LIB_SSL, 0, SSL_R_PRIVATE_KEY_MISMATCH),
index 7010f32daa180933d506b75867ddb3ff92868a14..ad858bbf8a9e07a5481dcc41d281f9751662c70b 100644 (file)
@@ -580,3 +580,4 @@ SSL_is_stream_local                     580 3_2_0   EXIST::FUNCTION:
 SSL_write_ex2                           ?      3_3_0   EXIST::FUNCTION:
 SSL_get_value_uint                      ?      3_3_0   EXIST::FUNCTION:
 SSL_set_value_uint                      ?      3_3_0   EXIST::FUNCTION:
+SSL_poll                                ?      3_3_0   EXIST::FUNCTION: