mirror of
https://github.com/openssl/openssl.git
synced 2024-12-13 12:03:48 +08:00
QUIC APL: Implement SSL_want
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/21915)
This commit is contained in:
parent
72ca0b88fc
commit
5debf07010
@ -57,6 +57,7 @@ __owur int ossl_quic_get_wpoll_descriptor(SSL *s, BIO_POLL_DESCRIPTOR *d);
|
||||
__owur int ossl_quic_get_net_read_desired(SSL *s);
|
||||
__owur int ossl_quic_get_net_write_desired(SSL *s);
|
||||
__owur int ossl_quic_get_error(const SSL *s, int i);
|
||||
__owur int ossl_quic_want(const SSL *s);
|
||||
__owur int ossl_quic_conn_get_blocking_mode(const SSL *s);
|
||||
__owur int ossl_quic_conn_set_blocking_mode(SSL *s, int blocking);
|
||||
__owur int ossl_quic_conn_shutdown(SSL *s, uint64_t flags,
|
||||
|
@ -2025,6 +2025,7 @@ SSL *ossl_quic_conn_stream_new(SSL *s, uint64_t flags)
|
||||
* above, all QUIC I/O is implemented using non-blocking mode internally.
|
||||
*
|
||||
* SSL_get_error => partially implemented by ossl_quic_get_error
|
||||
* SSL_want => ossl_quic_want
|
||||
* (BIO/)SSL_read => ossl_quic_read
|
||||
* (BIO/)SSL_write => ossl_quic_write
|
||||
* SSL_pending => ossl_quic_pending
|
||||
@ -2052,6 +2053,47 @@ int ossl_quic_get_error(const SSL *s, int i)
|
||||
return last_error;
|
||||
}
|
||||
|
||||
/* Converts a code returned by SSL_get_error to a code returned by SSL_want. */
|
||||
static int error_to_want(int error)
|
||||
{
|
||||
switch (error) {
|
||||
case SSL_ERROR_WANT_CONNECT: /* never used - UDP is connectionless */
|
||||
case SSL_ERROR_WANT_ACCEPT: /* never used - UDP is connectionless */
|
||||
case SSL_ERROR_ZERO_RETURN:
|
||||
default:
|
||||
return SSL_NOTHING;
|
||||
|
||||
case SSL_ERROR_WANT_READ:
|
||||
return SSL_READING;
|
||||
|
||||
case SSL_ERROR_WANT_WRITE:
|
||||
return SSL_WRITING;
|
||||
|
||||
case SSL_ERROR_WANT_CLIENT_HELLO_CB:
|
||||
return SSL_CLIENT_HELLO_CB;
|
||||
|
||||
case SSL_ERROR_WANT_X509_LOOKUP:
|
||||
return SSL_X509_LOOKUP;
|
||||
}
|
||||
}
|
||||
|
||||
/* SSL_want */
|
||||
int ossl_quic_want(const SSL *s)
|
||||
{
|
||||
QCTX ctx;
|
||||
int w;
|
||||
|
||||
if (!expect_quic(s, &ctx))
|
||||
return SSL_NOTHING;
|
||||
|
||||
quic_lock(ctx.qc);
|
||||
|
||||
w = error_to_want(ctx.is_stream ? ctx.xso->last_error : ctx.qc->last_error);
|
||||
|
||||
quic_unlock(ctx.qc);
|
||||
return w;
|
||||
}
|
||||
|
||||
/*
|
||||
* SSL_write
|
||||
* ---------
|
||||
|
@ -5501,6 +5501,11 @@ int SSL_want(const SSL *s)
|
||||
{
|
||||
const SSL_CONNECTION *sc = SSL_CONNECTION_FROM_CONST_SSL(s);
|
||||
|
||||
#ifndef OPENSSL_NO_QUIC
|
||||
if (IS_QUIC(s))
|
||||
return ossl_quic_want(s);
|
||||
#endif
|
||||
|
||||
if (sc == NULL)
|
||||
return SSL_NOTHING;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user