Skip to content

Commit

Permalink
QUIC Dispatch: Introduce the QUIC_XSO object
Browse files Browse the repository at this point in the history
The QUIC_XSO (external stream object) is to a QUIC stream what a
QUIC_CONNECTION is to a QUIC connection. Both are SSL objects. The
QUIC_CONNECTION type is the internal representation of a QUIC connection
SSL object (QCSO) and the QUIC_XSO type is the internal representation
of a QUIC stream SSL object (QSSO) type. The name QUIC_XSO has been
chosen to be distinct from the existing QUIC_STREAM type which is our
existing internal stream type. QUIC_XSO is to a QUIC_STREAM what
QUIC_CONNECTION is to a QUIC_CHANNEL; in other words, QUIC_CONNECTION
and QUIC_XSO objects form part of the API personality layer, whereas
QUIC_CHANNEL and QUIC_STREAM objects form part of the QUIC core and are
distinct from the API personality layer.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #20765)
  • Loading branch information
hlandau committed May 12, 2023
1 parent e88cdb8 commit f8636c7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions include/internal/quic_ssl.h
Expand Up @@ -38,6 +38,7 @@ __owur const SSL_CIPHER *ossl_quic_get_cipher(unsigned int u);
int ossl_quic_renegotiate_check(SSL *ssl, int initok);

typedef struct quic_conn_st QUIC_CONNECTION;
typedef struct quic_xso_st QUIC_XSO;

int ossl_quic_do_handshake(QUIC_CONNECTION *qc);
void ossl_quic_set_connect_state(QUIC_CONNECTION *qc);
Expand Down
16 changes: 8 additions & 8 deletions ssl/quic/quic_local.h
Expand Up @@ -167,11 +167,11 @@ void ossl_quic_conn_on_remote_conn_close(QUIC_CONNECTION *qc,
? (c QUIC_CONNECTION *)(ssl) \
: NULL))

# define QUIC_STREAM_FROM_SSL_int(ssl, c) \
# define QUIC_XSO_FROM_SSL_int(ssl, c) \
((ssl) == NULL ? NULL \
: ((ssl)->type == SSL_TYPE_QUIC_CONNECTION \
|| (ssl)->type == SSL_TYPE_QUIC_STREAM \
? (c QUIC_STREAM *)(ssl) \
|| (ssl)->type == SSL_TYPE_QUIC_XSO \
? (c QUIC_XSO *)(ssl) \
: NULL))

# define SSL_CONNECTION_FROM_QUIC_SSL_int(ssl, c) \
Expand All @@ -181,18 +181,18 @@ void ossl_quic_conn_on_remote_conn_close(QUIC_CONNECTION *qc,
: NULL))
# else
# define QUIC_CONNECTION_FROM_SSL_int(ssl, c) NULL
# define QUIC_STREAM_FROM_SSL_int(ssl, c) NULL
# define QUIC_XSO_FROM_SSL_int(ssl, c) NULL
# define SSL_CONNECTION_FROM_QUIC_SSL_int(ssl, c) NULL
# endif

# define QUIC_CONNECTION_FROM_SSL(ssl) \
QUIC_CONNECTION_FROM_SSL_int(ssl, SSL_CONNECTION_NO_CONST)
# define QUIC_CONNECTION_FROM_CONST_SSL(ssl) \
QUIC_CONNECTION_FROM_SSL_int(ssl, const)
# define QUIC_STREAM_FROM_SSL(ssl) \
QUIC_STREAM_FROM_SSL_int(ssl, SSL_CONNECTION_NO_CONST)
# define QUIC_STREAM_FROM_CONST_SSL(ssl) \
QUIC_STREAM_FROM_SSL_int(ssl, const)
# define QUIC_XSO_FROM_SSL(ssl) \
QUIC_XSO_FROM_SSL_int(ssl, SSL_CONNECTION_NO_CONST)
# define QUIC_XSO_FROM_CONST_SSL(ssl) \
QUIC_XSO_FROM_SSL_int(ssl, const)
# define SSL_CONNECTION_FROM_QUIC_SSL(ssl) \
SSL_CONNECTION_FROM_QUIC_SSL_int(ssl, SSL_CONNECTION_NO_CONST)
# define SSL_CONNECTION_FROM_CONST_QUIC_SSL(ssl) \
Expand Down
10 changes: 5 additions & 5 deletions ssl/ssl_lib.c
Expand Up @@ -931,7 +931,7 @@ int SSL_is_dtls(const SSL *s)
SSL_CONNECTION *sc = SSL_CONNECTION_FROM_SSL(s);

#ifndef OPENSSL_NO_QUIC
if (s->type == SSL_TYPE_QUIC_CONNECTION || s->type == SSL_TYPE_QUIC_STREAM)
if (s->type == SSL_TYPE_QUIC_CONNECTION || s->type == SSL_TYPE_QUIC_XSO)
return 0;
#endif

Expand All @@ -946,7 +946,7 @@ int SSL_is_tls(const SSL *s)
SSL_CONNECTION *sc = SSL_CONNECTION_FROM_SSL(s);

#ifndef OPENSSL_NO_QUIC
if (s->type == SSL_TYPE_QUIC_CONNECTION || s->type == SSL_TYPE_QUIC_STREAM)
if (s->type == SSL_TYPE_QUIC_CONNECTION || s->type == SSL_TYPE_QUIC_XSO)
return 0;
#endif

Expand All @@ -959,7 +959,7 @@ int SSL_is_tls(const SSL *s)
int SSL_is_quic(const SSL *s)
{
#ifndef OPENSSL_NO_QUIC
if (s->type == SSL_TYPE_QUIC_CONNECTION || s->type == SSL_TYPE_QUIC_STREAM)
if (s->type == SSL_TYPE_QUIC_CONNECTION || s->type == SSL_TYPE_QUIC_XSO)
return 1;
#endif
return 0;
Expand Down Expand Up @@ -4774,7 +4774,7 @@ const char *SSL_get_version(const SSL *s)

#ifndef OPENSSL_NO_QUIC
/* We only support QUICv1 - so if its QUIC its QUICv1 */
if (s->type == SSL_TYPE_QUIC_CONNECTION || s->type == SSL_TYPE_QUIC_STREAM)
if (s->type == SSL_TYPE_QUIC_CONNECTION || s->type == SSL_TYPE_QUIC_XSO)
return "QUICv1";
#endif

Expand Down Expand Up @@ -5116,7 +5116,7 @@ int SSL_version(const SSL *s)

#ifndef OPENSSL_NO_QUIC
/* We only support QUICv1 - so if its QUIC its QUICv1 */
if (s->type == SSL_TYPE_QUIC_CONNECTION || s->type == SSL_TYPE_QUIC_STREAM)
if (s->type == SSL_TYPE_QUIC_CONNECTION || s->type == SSL_TYPE_QUIC_XSO)
return OSSL_QUIC1_VERSION;
#endif
/* TODO(QUIC): Do we want to report QUIC version this way instead? */
Expand Down
2 changes: 1 addition & 1 deletion ssl/ssl_local.h
Expand Up @@ -1191,7 +1191,7 @@ typedef struct cert_pkey_st CERT_PKEY;

#define SSL_TYPE_SSL_CONNECTION 0
#define SSL_TYPE_QUIC_CONNECTION 1
#define SSL_TYPE_QUIC_STREAM 2
#define SSL_TYPE_QUIC_XSO 2

struct ssl_st {
int type;
Expand Down

0 comments on commit f8636c7

Please sign in to comment.