mirror of
https://github.com/openssl/openssl.git
synced 2025-02-17 14:32:04 +08:00
Add BIO poll descriptors
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19703)
This commit is contained in:
parent
4ed9e0a1e3
commit
68801bcb76
@ -490,6 +490,16 @@ int BIO_recvmmsg(BIO *b, BIO_MSG *msg,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int BIO_get_rpoll_descriptor(BIO *b, BIO_POLL_DESCRIPTOR *desc)
|
||||
{
|
||||
return BIO_ctrl(b, BIO_CTRL_GET_RPOLL_DESCRIPTOR, 0, desc);
|
||||
}
|
||||
|
||||
int BIO_get_wpoll_descriptor(BIO *b, BIO_POLL_DESCRIPTOR *desc)
|
||||
{
|
||||
return BIO_ctrl(b, BIO_CTRL_GET_WPOLL_DESCRIPTOR, 0, desc);
|
||||
}
|
||||
|
||||
int BIO_puts(BIO *b, const char *buf)
|
||||
{
|
||||
int ret;
|
||||
|
@ -945,6 +945,16 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
*(int *)ptr = data->local_addr_enabled;
|
||||
break;
|
||||
|
||||
case BIO_CTRL_GET_RPOLL_DESCRIPTOR:
|
||||
case BIO_CTRL_GET_WPOLL_DESCRIPTOR:
|
||||
{
|
||||
BIO_POLL_DESCRIPTOR *pd = ptr;
|
||||
|
||||
pd->type = BIO_POLL_DESCRIPTOR_TYPE_SOCK_FD;
|
||||
pd->value.fd = b->num;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = 0;
|
||||
break;
|
||||
|
@ -187,6 +187,9 @@ extern "C" {
|
||||
* # define BIO_CTRL_SET_KTLS_TX_ZEROCOPY_SENDFILE 90
|
||||
*/
|
||||
|
||||
# define BIO_CTRL_GET_RPOLL_DESCRIPTOR 90
|
||||
# define BIO_CTRL_GET_WPOLL_DESCRIPTOR 91
|
||||
|
||||
# define BIO_DGRAM_CAP_NONE 0U
|
||||
# define BIO_DGRAM_CAP_HANDLES_SRC_ADDR (1U << 0)
|
||||
# define BIO_DGRAM_CAP_HANDLES_DST_ADDR (1U << 1)
|
||||
@ -377,6 +380,22 @@ typedef struct bio_mmsg_cb_args_st {
|
||||
size_t *msgs_processed;
|
||||
} BIO_MMSG_CB_ARGS;
|
||||
|
||||
#define BIO_POLL_DESCRIPTOR_TYPE_NONE 0
|
||||
#define BIO_POLL_DESCRIPTOR_TYPE_SOCK_FD 1
|
||||
#define BIO_POLL_DESCRIPTOR_CUSTOM_START 8192
|
||||
#define BIO_POLL_DESCRIPTOR_NUM_CUSTOM 4
|
||||
|
||||
typedef struct bio_poll_descriptor_st {
|
||||
int type;
|
||||
union {
|
||||
int fd;
|
||||
union {
|
||||
void *ptr;
|
||||
uint64_t u64;
|
||||
} custom[BIO_POLL_DESCRIPTOR_NUM_CUSTOM];
|
||||
} value;
|
||||
} BIO_POLL_DESCRIPTOR;
|
||||
|
||||
/*
|
||||
* #define BIO_CONN_get_param_hostname BIO_ctrl
|
||||
*/
|
||||
@ -690,6 +709,8 @@ int BIO_write_ex(BIO *b, const void *data, size_t dlen, size_t *written);
|
||||
__owur int BIO_sendmmsg(BIO *b, BIO_MSG *msg,
|
||||
size_t stride, size_t num_msg, uint64_t flags,
|
||||
size_t *msgs_processed);
|
||||
__owur int BIO_get_rpoll_descriptor(BIO *b, BIO_POLL_DESCRIPTOR *desc);
|
||||
__owur int BIO_get_wpoll_descriptor(BIO *b, BIO_POLL_DESCRIPTOR *desc);
|
||||
int BIO_puts(BIO *bp, const char *buf);
|
||||
int BIO_indent(BIO *b, int indent, int max);
|
||||
long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg);
|
||||
|
@ -2247,6 +2247,10 @@ size_t SSL_get_num_tickets(const SSL *s);
|
||||
int SSL_CTX_set_num_tickets(SSL_CTX *ctx, size_t num_tickets);
|
||||
size_t SSL_CTX_get_num_tickets(const SSL_CTX *ctx);
|
||||
|
||||
/* QUIC support */
|
||||
__owur int SSL_get_rpoll_descriptor(SSL *s, BIO_POLL_DESCRIPTOR *desc);
|
||||
__owur int SSL_get_wpoll_descriptor(SSL *s, BIO_POLL_DESCRIPTOR *desc);
|
||||
|
||||
# ifndef OPENSSL_NO_DEPRECATED_1_1_0
|
||||
# define SSL_cache_hit(s) SSL_session_reused(s)
|
||||
# endif
|
||||
|
@ -385,6 +385,14 @@ static long ssl_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
case BIO_CTRL_SET_CALLBACK:
|
||||
ret = 0; /* use callback ctrl */
|
||||
break;
|
||||
case BIO_CTRL_GET_RPOLL_DESCRIPTOR:
|
||||
if (!SSL_get_rpoll_descriptor(ssl, (BIO_POLL_DESCRIPTOR *)ptr))
|
||||
ret = 0;
|
||||
break;
|
||||
case BIO_CTRL_GET_WPOLL_DESCRIPTOR:
|
||||
if (!SSL_get_wpoll_descriptor(ssl, (BIO_POLL_DESCRIPTOR *)ptr))
|
||||
ret = 0;
|
||||
break;
|
||||
default:
|
||||
ret = BIO_ctrl(sc->rbio, cmd, num, ptr);
|
||||
break;
|
||||
|
@ -6942,3 +6942,31 @@ int SSL_CTX_set0_tmp_dh_pkey(SSL_CTX *ctx, EVP_PKEY *dhpkey)
|
||||
ctx->cert->dh_tmp = dhpkey;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int SSL_get_rpoll_descriptor(SSL *s, BIO_POLL_DESCRIPTOR *desc)
|
||||
{
|
||||
#ifndef OPENSSL_NO_QUIC
|
||||
QUIC_CONNECTION *qc = QUIC_CONNECTION_FROM_SSL(s);
|
||||
|
||||
if (qc == NULL)
|
||||
return -1;
|
||||
|
||||
return -1; /* TODO(QUIC) */
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int SSL_get_wpoll_descriptor(SSL *s, BIO_POLL_DESCRIPTOR *desc)
|
||||
{
|
||||
#ifndef OPENSSL_NO_QUIC
|
||||
QUIC_CONNECTION *qc = QUIC_CONNECTION_FROM_SSL(s);
|
||||
|
||||
if (qc == NULL)
|
||||
return -1;
|
||||
|
||||
return -1; /* TODO(QUIC) */
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user