Skip to content

Commit

Permalink
QUIC DISPATCH/APL: Implement SSL_get_stream_id
Browse files Browse the repository at this point in the history
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 1bca3f1 commit 19cb088
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/internal/quic_ssl.h
Expand Up @@ -68,6 +68,7 @@ __owur int ossl_quic_conn_set_initial_peer_addr(SSL *s,
__owur SSL *ossl_quic_conn_stream_new(SSL *s, uint64_t flags);
__owur SSL *ossl_quic_get0_connection(SSL *s);
__owur int ossl_quic_get_stream_type(SSL *s);
__owur uint64_t ossl_quic_get_stream_id(SSL *s);

/*
* Used to override ossl_time_now() for debug purposes. Must be called before
Expand Down
2 changes: 2 additions & 0 deletions include/openssl/ssl.h.in
Expand Up @@ -2275,6 +2275,8 @@ __owur int SSL_is_connection(SSL *s);
#define SSL_STREAM_TYPE_BIDI (SSL_STREAM_TYPE_READ | SSL_STREAM_TYPE_WRITE)
__owur int SSL_get_stream_type(SSL *s);

__owur uint64_t SSL_get_stream_id(SSL *s);

#define SSL_STREAM_FLAG_UNI (1U << 0)
__owur SSL *SSL_new_stream(SSL *s, uint64_t flags);

Expand Down
14 changes: 14 additions & 0 deletions ssl/quic/quic_impl.c
Expand Up @@ -1867,6 +1867,20 @@ int ossl_quic_get_stream_type(SSL *s)
return SSL_STREAM_TYPE_WRITE;
}

/*
* SSL_get_stream_id
* -----------------
*/
uint64_t ossl_quic_get_stream_id(SSL *s)
{
QCTX ctx;

if (!expect_quic_with_stream(s, /*remote_init=*/-1, &ctx))
return UINT64_MAX;

return ctx.xso->stream->id;
}

/*
* QUIC Front-End I/O API: SSL_CTX Management
* ==========================================
Expand Down
12 changes: 12 additions & 0 deletions ssl/ssl_lib.c
Expand Up @@ -7340,6 +7340,18 @@ int SSL_get_stream_type(SSL *s)
#endif
}

uint64_t SSL_get_stream_id(SSL *s)
{
#ifndef OPENSSL_NO_QUIC
if (!IS_QUIC(s))
return UINT64_MAX;

return ossl_quic_get_stream_id(s);
#else
return UINT64_MAX;
#endif
}

int SSL_add_expected_rpk(SSL *s, EVP_PKEY *rpk)
{
unsigned char *data = NULL;
Expand Down

0 comments on commit 19cb088

Please sign in to comment.