1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-23 16:48:49 -05:00

vtls: factor out Curl_ssl_getsock to field of Curl_ssl

Closes #6558
This commit is contained in:
Jacob Hoffman-Andrews 2021-02-02 17:54:52 -08:00 committed by Daniel Stenberg
parent 8a644f3355
commit c30bf22f1c
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
11 changed files with 29 additions and 13 deletions

View File

@ -855,6 +855,7 @@ const struct Curl_ssl Curl_ssl_bearssl = {
Curl_none_cert_status_request, Curl_none_cert_status_request,
bearssl_connect, bearssl_connect,
bearssl_connect_nonblocking, bearssl_connect_nonblocking,
Curl_ssl_getsock,
bearssl_get_internals, bearssl_get_internals,
bearssl_close, bearssl_close,
Curl_none_close_all, Curl_none_close_all,

View File

@ -1671,6 +1671,7 @@ const struct Curl_ssl Curl_ssl_gnutls = {
gtls_cert_status_request, /* cert_status_request */ gtls_cert_status_request, /* cert_status_request */
gtls_connect, /* connect */ gtls_connect, /* connect */
gtls_connect_nonblocking, /* connect_nonblocking */ gtls_connect_nonblocking, /* connect_nonblocking */
Curl_ssl_getsock, /* getsock */
gtls_get_internals, /* get_internals */ gtls_get_internals, /* get_internals */
gtls_close, /* close_one */ gtls_close, /* close_one */
Curl_none_close_all, /* close_all */ Curl_none_close_all, /* close_all */

View File

@ -1100,6 +1100,7 @@ const struct Curl_ssl Curl_ssl_mbedtls = {
Curl_none_cert_status_request, /* cert_status_request */ Curl_none_cert_status_request, /* cert_status_request */
mbedtls_connect, /* connect */ mbedtls_connect, /* connect */
mbedtls_connect_nonblocking, /* connect_nonblocking */ mbedtls_connect_nonblocking, /* connect_nonblocking */
Curl_ssl_getsock, /* getsock */
mbedtls_get_internals, /* get_internals */ mbedtls_get_internals, /* get_internals */
mbedtls_close, /* close_one */ mbedtls_close, /* close_one */
mbedtls_close_all, /* close_all */ mbedtls_close_all, /* close_all */

View File

@ -654,6 +654,7 @@ const struct Curl_ssl Curl_ssl_mesalink = {
Curl_none_cert_status_request, /* cert_status_request */ Curl_none_cert_status_request, /* cert_status_request */
mesalink_connect, /* connect */ mesalink_connect, /* connect */
mesalink_connect_nonblocking, /* connect_nonblocking */ mesalink_connect_nonblocking, /* connect_nonblocking */
Curl_ssl_getsock, /* getsock */
mesalink_get_internals, /* get_internals */ mesalink_get_internals, /* get_internals */
mesalink_close, /* close_one */ mesalink_close, /* close_one */
Curl_none_close_all, /* close_all */ Curl_none_close_all, /* close_all */

View File

@ -2435,6 +2435,7 @@ const struct Curl_ssl Curl_ssl_nss = {
nss_cert_status_request, /* cert_status_request */ nss_cert_status_request, /* cert_status_request */
nss_connect, /* connect */ nss_connect, /* connect */
nss_connect_nonblocking, /* connect_nonblocking */ nss_connect_nonblocking, /* connect_nonblocking */
Curl_ssl_getsock, /* getsock */
nss_get_internals, /* get_internals */ nss_get_internals, /* get_internals */
nss_close, /* close_one */ nss_close, /* close_one */
Curl_none_close_all, /* close_all */ Curl_none_close_all, /* close_all */

View File

@ -4477,6 +4477,7 @@ const struct Curl_ssl Curl_ssl_openssl = {
ossl_cert_status_request, /* cert_status_request */ ossl_cert_status_request, /* cert_status_request */
ossl_connect, /* connect */ ossl_connect, /* connect */
ossl_connect_nonblocking, /* connect_nonblocking */ ossl_connect_nonblocking, /* connect_nonblocking */
Curl_ssl_getsock, /* getsock */
ossl_get_internals, /* get_internals */ ossl_get_internals, /* get_internals */
ossl_close, /* close_one */ ossl_close, /* close_one */
ossl_close_all, /* close_all */ ossl_close_all, /* close_all */

View File

@ -2418,6 +2418,7 @@ const struct Curl_ssl Curl_ssl_schannel = {
Curl_none_cert_status_request, /* cert_status_request */ Curl_none_cert_status_request, /* cert_status_request */
schannel_connect, /* connect */ schannel_connect, /* connect */
schannel_connect_nonblocking, /* connect_nonblocking */ schannel_connect_nonblocking, /* connect_nonblocking */
Curl_ssl_getsock, /* getsock */
schannel_get_internals, /* get_internals */ schannel_get_internals, /* get_internals */
schannel_close, /* close_one */ schannel_close, /* close_one */
Curl_none_close_all, /* close_all */ Curl_none_close_all, /* close_all */

View File

@ -3301,6 +3301,7 @@ const struct Curl_ssl Curl_ssl_sectransp = {
Curl_none_cert_status_request, /* cert_status_request */ Curl_none_cert_status_request, /* cert_status_request */
sectransp_connect, /* connect */ sectransp_connect, /* connect */
sectransp_connect_nonblocking, /* connect_nonblocking */ sectransp_connect_nonblocking, /* connect_nonblocking */
Curl_ssl_getsock, /* getsock */
sectransp_get_internals, /* get_internals */ sectransp_get_internals, /* get_internals */
sectransp_close, /* close_one */ sectransp_close, /* close_one */
Curl_none_close_all, /* close_all */ Curl_none_close_all, /* close_all */

View File

@ -593,9 +593,6 @@ void Curl_ssl_close_all(struct Curl_easy *data)
Curl_ssl->close_all(data); Curl_ssl->close_all(data);
} }
#if defined(USE_OPENSSL) || defined(USE_GNUTLS) || defined(USE_SCHANNEL) || \
defined(USE_SECTRANSP) || defined(USE_NSS) || \
defined(USE_MBEDTLS) || defined(USE_WOLFSSL) || defined(USE_BEARSSL)
int Curl_ssl_getsock(struct connectdata *conn, curl_socket_t *socks) int Curl_ssl_getsock(struct connectdata *conn, curl_socket_t *socks)
{ {
struct ssl_connect_data *connssl = &conn->ssl[FIRSTSOCKET]; struct ssl_connect_data *connssl = &conn->ssl[FIRSTSOCKET];
@ -613,16 +610,6 @@ int Curl_ssl_getsock(struct connectdata *conn, curl_socket_t *socks)
return GETSOCK_BLANK; return GETSOCK_BLANK;
} }
#else
int Curl_ssl_getsock(struct connectdata *conn,
curl_socket_t *socks)
{
(void)conn;
(void)socks;
return GETSOCK_BLANK;
}
/* USE_OPENSSL || USE_GNUTLS || USE_SCHANNEL || USE_SECTRANSP || USE_NSS */
#endif
void Curl_ssl_close(struct Curl_easy *data, struct connectdata *conn, void Curl_ssl_close(struct Curl_easy *data, struct connectdata *conn,
int sockindex) int sockindex)
@ -1170,6 +1157,13 @@ static CURLcode multissl_connect_nonblocking(struct Curl_easy *data,
return Curl_ssl->connect_nonblocking(data, conn, sockindex, done); return Curl_ssl->connect_nonblocking(data, conn, sockindex, done);
} }
static int multissl_getsock(struct connectdata *conn, curl_socket_t *socks)
{
if(multissl_setup(NULL))
return 0;
return Curl_ssl->getsock(conn, socks);
}
static void *multissl_get_internals(struct ssl_connect_data *connssl, static void *multissl_get_internals(struct ssl_connect_data *connssl,
CURLINFO info) CURLINFO info)
{ {
@ -1201,6 +1195,7 @@ static const struct Curl_ssl Curl_ssl_multi = {
Curl_none_cert_status_request, /* cert_status_request */ Curl_none_cert_status_request, /* cert_status_request */
multissl_connect, /* connect */ multissl_connect, /* connect */
multissl_connect_nonblocking, /* connect_nonblocking */ multissl_connect_nonblocking, /* connect_nonblocking */
multissl_getsock, /* getsock */
multissl_get_internals, /* get_internals */ multissl_get_internals, /* get_internals */
multissl_close, /* close_one */ multissl_close, /* close_one */
Curl_none_close_all, /* close_all */ Curl_none_close_all, /* close_all */

View File

@ -62,6 +62,14 @@ struct Curl_ssl {
CURLcode (*connect_nonblocking)(struct Curl_easy *data, CURLcode (*connect_nonblocking)(struct Curl_easy *data,
struct connectdata *conn, int sockindex, struct connectdata *conn, int sockindex,
bool *done); bool *done);
/* If the SSL backend wants to read or write on this connection during a
handshake, set socks[0] to the connection's FIRSTSOCKET, and return
a bitmap indicating read or write with GETSOCK_WRITESOCK(0) or
GETSOCK_READSOCK(0). Otherwise return GETSOCK_BLANK.
Mandatory. */
int (*getsock)(struct connectdata *conn, curl_socket_t *socks);
void *(*get_internals)(struct ssl_connect_data *connssl, CURLINFO info); void *(*get_internals)(struct ssl_connect_data *connssl, CURLINFO info);
void (*close_one)(struct Curl_easy *data, struct connectdata *conn, void (*close_one)(struct Curl_easy *data, struct connectdata *conn,
int sockindex); int sockindex);
@ -158,6 +166,10 @@ bool Curl_ssl_config_matches(struct ssl_primary_config *data,
bool Curl_clone_primary_ssl_config(struct ssl_primary_config *source, bool Curl_clone_primary_ssl_config(struct ssl_primary_config *source,
struct ssl_primary_config *dest); struct ssl_primary_config *dest);
void Curl_free_primary_ssl_config(struct ssl_primary_config *sslc); void Curl_free_primary_ssl_config(struct ssl_primary_config *sslc);
/* An implementation of the getsock field of Curl_ssl that relies
on the ssl_connect_state enum. Asks for read or write depending
on whether conn->state is ssl_connect_2_reading or
ssl_connect_2_writing. */
int Curl_ssl_getsock(struct connectdata *conn, curl_socket_t *socks); int Curl_ssl_getsock(struct connectdata *conn, curl_socket_t *socks);
int Curl_ssl_backend(void); int Curl_ssl_backend(void);

View File

@ -1152,6 +1152,7 @@ const struct Curl_ssl Curl_ssl_wolfssl = {
Curl_none_cert_status_request, /* cert_status_request */ Curl_none_cert_status_request, /* cert_status_request */
wolfssl_connect, /* connect */ wolfssl_connect, /* connect */
wolfssl_connect_nonblocking, /* connect_nonblocking */ wolfssl_connect_nonblocking, /* connect_nonblocking */
Curl_ssl_getsock, /* getsock */
wolfssl_get_internals, /* get_internals */ wolfssl_get_internals, /* get_internals */
wolfssl_close, /* close_one */ wolfssl_close, /* close_one */
Curl_none_close_all, /* close_all */ Curl_none_close_all, /* close_all */