]> git.ipfire.org Git - thirdparty/openssl.git/blobdiff - ssl/quic/quic_local.h
Fix the SSL_CIPHER_find() function when used with a QCSO
[thirdparty/openssl.git] / ssl / quic / quic_local.h
index d4088d4b699c5ce4907b99d300eab26fcee4e88a..063df7796a2410f6d5539336943fcd1546176c22 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2022-2023 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -41,8 +41,18 @@ struct quic_xso_st {
     /* The stream object. Always non-NULL for as long as the XSO exists. */
     QUIC_STREAM                     *stream;
 
-    /* Is this stream in blocking mode? */
-    unsigned int                    blocking                : 1;
+    /*
+     * Has this stream been logically configured into blocking mode? Only
+     * meaningful if desires_blocking_set is 1. Ignored if blocking is not
+     * currently possible given QUIC_CONNECTION configuration.
+     */
+    unsigned int                    desires_blocking        : 1;
+
+    /*
+     * Has SSL_set_blocking_mode been called on this stream? If not set, we
+     * inherit from the QUIC_CONNECTION blocking state.
+     */
+    unsigned int                    desires_blocking_set    : 1;
 
     /*
      * This state tracks SSL_write all-or-nothing (AON) write semantics
@@ -85,6 +95,9 @@ struct quic_xso_st {
     /* SSL_set_mode */
     uint32_t                        ssl_mode;
 
+    /* SSL_set_options */
+    uint64_t                        ssl_options;
+
     /*
      * Last 'normal' error during an app-level I/O operation, used by
      * SSL_get_error(); used to track data-path errors like SSL_ERROR_WANT_READ
@@ -151,10 +164,6 @@ struct quic_conn_st {
     /* Have we started? */
     unsigned int                    started                 : 1;
 
-    /* Can the read and write network BIOs support blocking? */
-    unsigned int                    can_poll_net_rbio       : 1;
-    unsigned int                    can_poll_net_wbio       : 1;
-
     /*
      * This is 1 if we were instantiated using a QUIC server method
      * (for future use).
@@ -173,18 +182,35 @@ struct quic_conn_st {
     /* Do connection-level operations (e.g. handshakes) run in blocking mode? */
     unsigned int                    blocking                : 1;
 
-    /* Do newly created streams start in blocking mode? Inherited by new XSOs. */
-    unsigned int                    default_blocking        : 1;
+    /* Does the application want blocking mode? */
+    unsigned int                    desires_blocking        : 1;
 
     /* Have we created a default XSO yet? */
     unsigned int                    default_xso_created     : 1;
 
+    /*
+     * Pre-TERMINATING shutdown phase in which we are flushing streams.
+     * Monotonically transitions to 1.
+     * New streams cannot be created in this state.
+     */
+    unsigned int                    shutting_down           : 1;
+
+    /* Have we probed the BIOs for addressing support? */
+    unsigned int                    addressing_probe_done   : 1;
+
+    /* Are we using addressed mode (BIO_sendmmsg with non-NULL peer)? */
+    unsigned int                    addressed_mode_w        : 1;
+    unsigned int                    addressed_mode_r        : 1;
+
     /* Default stream type. Defaults to SSL_DEFAULT_STREAM_MODE_AUTO_BIDI. */
     uint32_t                        default_stream_mode;
 
     /* SSL_set_mode. This is not used directly but inherited by new XSOs. */
     uint32_t                        default_ssl_mode;
 
+    /* SSL_set_options. This is not used directly but inherited by new XSOs. */
+    uint64_t                        default_ssl_options;
+
     /* SSL_set_incoming_stream_policy. */
     int                             incoming_stream_policy;
     uint64_t                        incoming_stream_aec;
@@ -195,11 +221,6 @@ struct quic_conn_st {
      * and SSL_ERROR_WANT_WRITE.
      */
     int                             last_error;
-
-    /* Message callback related arguments */
-    ossl_msg_cb                     msg_callback;
-    void                            *msg_callback_arg;
-    SSL                             *msg_callback_s;
 };
 
 /* Internal calls to the QUIC CSM which come from various places. */
@@ -222,6 +243,10 @@ int ossl_quic_trace(int write_p, int version, int content_type,
                     const void *buf, size_t msglen, SSL *ssl, void *arg);
 
 #  define OSSL_QUIC_ANY_VERSION 0xFFFFF
+#  define IS_QUIC_METHOD(m) \
+    ((m) == OSSL_QUIC_client_method() || \
+     (m) == OSSL_QUIC_client_thread_method())
+#  define IS_QUIC_CTX(ctx)          IS_QUIC_METHOD((ctx)->method)
 
 #  define QUIC_CONNECTION_FROM_SSL_int(ssl, c)   \
      ((ssl) == NULL ? NULL                       \
@@ -252,6 +277,8 @@ int ossl_quic_trace(int write_p, int version, int content_type,
 #  define QUIC_XSO_FROM_SSL_int(ssl, c) NULL
 #  define SSL_CONNECTION_FROM_QUIC_SSL_int(ssl, c) NULL
 #  define IS_QUIC(ssl) 0
+#  define IS_QUIC_CTX(ctx) 0
+#  define IS_QUIC_METHOD(m) 0
 # endif
 
 # define QUIC_CONNECTION_FROM_SSL(ssl) \
@@ -279,7 +306,7 @@ const SSL_METHOD *func_name(void)  \
                 ossl_quic_free, \
                 ossl_quic_reset, \
                 ossl_quic_init, \
-                ossl_quic_clear, \
+                NULL /* clear */, \
                 ossl_quic_deinit, \
                 q_accept, \
                 q_connect, \
@@ -294,7 +321,7 @@ const SSL_METHOD *func_name(void)  \
                 NULL /* dispatch_alert */, \
                 ossl_quic_ctrl, \
                 ossl_quic_ctx_ctrl, \
-                NULL /* get_cipher_by_char */, \
+                ossl_quic_get_cipher_by_char, \
                 NULL /* put_cipher_by_char */, \
                 ossl_quic_pending, \
                 ossl_quic_num_ciphers, \