diff options
Diffstat (limited to 'ssl/quic/quic_local.h')
-rw-r--r-- | ssl/quic/quic_local.h | 130 |
1 files changed, 80 insertions, 50 deletions
diff --git a/ssl/quic/quic_local.h b/ssl/quic/quic_local.h index 903e681008..3906a20357 100644 --- a/ssl/quic/quic_local.h +++ b/ssl/quic/quic_local.h @@ -26,6 +26,66 @@ # ifndef OPENSSL_NO_QUIC +/* + * QUIC stream SSL object (QCSO) type. This implements the API personality layer + * for QSSO objects, wrapping the QUIC-native QUIC_STREAM object and tracking + * state required by the libssl API personality. + */ +struct quic_xso_st { + /* SSL object common header. */ + struct ssl_st ssl; + + /* The connection this stream is associated with. Always non-NULL. */ + QUIC_CONNECTION *conn; + + /* 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; + + /* + * This state tracks SSL_write all-or-nothing (AON) write semantics + * emulation. + * + * Example chronology: + * + * t=0: aon_write_in_progress=0 + * t=1: SSL_write(ssl, b1, l1) called; + * too big to enqueue into sstream at once, SSL_ERROR_WANT_WRITE; + * aon_write_in_progress=1; aon_buf_base=b1; aon_buf_len=l1; + * aon_buf_pos < l1 (depends on how much room was in sstream); + * t=2: SSL_write(ssl, b2, l2); + * b2 must equal b1 (validated unless ACCEPT_MOVING_WRITE_BUFFER) + * l2 must equal l1 (always validated) + * append into sstream from [b2 + aon_buf_pos, b2 + aon_buf_len) + * if done, aon_write_in_progess=0 + * + */ + /* Is an AON write in progress? */ + unsigned int aon_write_in_progress : 1; + /* + * The base buffer pointer the caller passed us for the initial AON write + * call. We use this for validation purposes unless + * ACCEPT_MOVING_WRITE_BUFFER is enabled. + * + * NOTE: We never dereference this, as the caller might pass a different + * (but identical) buffer if using ACCEPT_MOVING_WRITE_BUFFER. It is for + * validation by pointer comparison only. + */ + const unsigned char *aon_buf_base; + /* The total length of the AON buffer being sent, in bytes. */ + size_t aon_buf_len; + /* + * The position in the AON buffer up to which we have successfully sent data + * so far. + */ + size_t aon_buf_pos; + + /* SSL_set_mode */ + uint32_t ssl_mode; +}; + struct quic_conn_st { /* * ssl_st is a common header for ordinary SSL objects, QUIC connection @@ -57,8 +117,11 @@ struct quic_conn_st { */ CRYPTO_MUTEX *mutex; - /* Our single bidirectional application data stream. */ - QUIC_STREAM *stream0; + /* + * If we have a default stream attached, this is the internal XSO + * object. If there is no default stream, this is NULL. + */ + QUIC_XSO *default_xso; /* The network read and write BIOs. */ BIO *net_rbio, *net_wbio; @@ -78,9 +141,6 @@ struct quic_conn_st { /* Have we started? */ unsigned int started : 1; - /* Are we in blocking mode? */ - unsigned int blocking : 1; - /* Can the read and write network BIOs support blocking? */ unsigned int can_poll_net_rbio : 1; unsigned int can_poll_net_wbio : 1; @@ -100,46 +160,14 @@ struct quic_conn_st { /* Are we using thread assisted mode? Never changes after init. */ unsigned int is_thread_assisted : 1; - /* - * This state tracks SSL_write all-or-nothing (AON) write semantics - * emulation. - * - * Example chronology: - * - * t=0: aon_write_in_progress=0 - * t=1: SSL_write(ssl, b1, l1) called; - * too big to enqueue into sstream at once, SSL_ERROR_WANT_WRITE; - * aon_write_in_progress=1; aon_buf_base=b1; aon_buf_len=l1; - * aon_buf_pos < l1 (depends on how much room was in sstream); - * t=2: SSL_write(ssl, b2, l2); - * b2 must equal b1 (validated unless ACCEPT_MOVING_WRITE_BUFFER) - * l2 must equal l1 (always validated) - * append into sstream from [b2 + aon_buf_pos, b2 + aon_buf_len) - * if done, aon_write_in_progess=0 - * - */ - /* Is an AON write in progress? */ - unsigned int aon_write_in_progress : 1; - /* - * The base buffer pointer the caller passed us for the initial AON write - * call. We use this for validation purposes unless - * ACCEPT_MOVING_WRITE_BUFFER is enabled. - * - * NOTE: We never dereference this, as the caller might pass a different - * (but identical) buffer if using ACCEPT_MOVING_WRITE_BUFFER. It is for - * validation by pointer comparison only. - */ - const unsigned char *aon_buf_base; - /* The total length of the AON buffer being sent, in bytes. */ - size_t aon_buf_len; - /* - * The position in the AON buffer up to which we have successfully sent data - * so far. - */ - size_t aon_buf_pos; + /* Do connection-level operations (e.g. handshakes) run in blocking mode? */ + unsigned int blocking : 1; - /* SSL_set_mode */ - uint32_t ssl_mode; + /* Do newly created streams start in blocking mode? Inherited by new XSOs. */ + unsigned int default_blocking : 1; + + /* SSL_set_mode. This is not used directly but inherited by new XSOs. */ + uint32_t default_ssl_mode; /* * Last 'normal' error during an app-level I/O operation, used by @@ -173,12 +201,14 @@ void ossl_quic_conn_on_remote_conn_close(QUIC_CONNECTION *qc, ? (c QUIC_CONNECTION *)(ssl) \ : NULL)) -# define QUIC_XSO_FROM_SSL_int(ssl, c) \ - ((ssl) == NULL ? NULL \ - : ((ssl)->type == SSL_TYPE_QUIC_CONNECTION \ - || (ssl)->type == SSL_TYPE_QUIC_XSO \ - ? (c QUIC_XSO *)(ssl) \ - : NULL)) +# define QUIC_XSO_FROM_SSL_int(ssl, c) \ + ((ssl) == NULL \ + ? NULL \ + : (((ssl)->type == SSL_TYPE_QUIC_XSO \ + ? (c QUIC_XSO *)(ssl) \ + : ((ssl)->type == SSL_TYPE_QUIC_CONNECTION \ + ? (c QUIC_XSO *)((QUIC_CONNECTION *)(ssl))->default_xso \ + : NULL)))) # define SSL_CONNECTION_FROM_QUIC_SSL_int(ssl, c) \ ((ssl) == NULL ? NULL \ |