mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 20:24:39 +02:00
allow separate set fds for read/write, helpful for DTLS multicast
This commit is contained in:
@@ -3387,7 +3387,8 @@ int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx)
|
|||||||
ssl->dtls_timeout_init = DTLS_TIMEOUT_INIT;
|
ssl->dtls_timeout_init = DTLS_TIMEOUT_INIT;
|
||||||
ssl->dtls_timeout_max = DTLS_TIMEOUT_MAX;
|
ssl->dtls_timeout_max = DTLS_TIMEOUT_MAX;
|
||||||
ssl->dtls_timeout = ssl->dtls_timeout_init;
|
ssl->dtls_timeout = ssl->dtls_timeout_init;
|
||||||
ssl->buffers.dtlsCtx.fd = -1;
|
ssl->buffers.dtlsCtx.rfd = -1;
|
||||||
|
ssl->buffers.dtlsCtx.wfd = -1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NO_OLD_TLS
|
#ifndef NO_OLD_TLS
|
||||||
|
4
src/io.c
4
src/io.c
@@ -398,7 +398,7 @@ int EmbedReceiveFrom(WOLFSSL *ssl, char *buf, int sz, void *ctx)
|
|||||||
WOLFSSL_DTLS_CTX* dtlsCtx = (WOLFSSL_DTLS_CTX*)ctx;
|
WOLFSSL_DTLS_CTX* dtlsCtx = (WOLFSSL_DTLS_CTX*)ctx;
|
||||||
int recvd;
|
int recvd;
|
||||||
int err;
|
int err;
|
||||||
int sd = dtlsCtx->fd;
|
int sd = dtlsCtx->rfd;
|
||||||
int dtls_timeout = wolfSSL_dtls_get_current_timeout(ssl);
|
int dtls_timeout = wolfSSL_dtls_get_current_timeout(ssl);
|
||||||
struct sockaddr_storage peer;
|
struct sockaddr_storage peer;
|
||||||
XSOCKLENT peerSz = sizeof(peer);
|
XSOCKLENT peerSz = sizeof(peer);
|
||||||
@@ -477,7 +477,7 @@ int EmbedReceiveFrom(WOLFSSL *ssl, char *buf, int sz, void *ctx)
|
|||||||
int EmbedSendTo(WOLFSSL* ssl, char *buf, int sz, void *ctx)
|
int EmbedSendTo(WOLFSSL* ssl, char *buf, int sz, void *ctx)
|
||||||
{
|
{
|
||||||
WOLFSSL_DTLS_CTX* dtlsCtx = (WOLFSSL_DTLS_CTX*)ctx;
|
WOLFSSL_DTLS_CTX* dtlsCtx = (WOLFSSL_DTLS_CTX*)ctx;
|
||||||
int sd = dtlsCtx->fd;
|
int sd = dtlsCtx->wfd;
|
||||||
int sent;
|
int sent;
|
||||||
int len = sz;
|
int len = sz;
|
||||||
int err;
|
int err;
|
||||||
|
47
src/ssl.c
47
src/ssl.c
@@ -431,29 +431,64 @@ int wolfSSL_use_old_poly(WOLFSSL* ssl, int value)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int wolfSSL_set_fd(WOLFSSL* ssl, int fd)
|
int wolfSSL_set_fd(WOLFSSL* ssl, int fd)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
WOLFSSL_ENTER("SSL_set_fd");
|
WOLFSSL_ENTER("SSL_set_fd");
|
||||||
|
|
||||||
|
ret = wolfSSL_set_read_fd(ssl, fd);
|
||||||
|
if (ret == SSL_SUCCESS) {
|
||||||
|
ret = wolfSSL_set_write_fd(ssl, fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int wolfSSL_set_read_fd(WOLFSSL* ssl, int fd)
|
||||||
|
{
|
||||||
|
WOLFSSL_ENTER("SSL_set_read_fd");
|
||||||
|
|
||||||
if (ssl == NULL) {
|
if (ssl == NULL) {
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssl->rfd = fd; /* not used directly to allow IO callbacks */
|
ssl->rfd = fd; /* not used directly to allow IO callbacks */
|
||||||
ssl->wfd = fd;
|
|
||||||
|
|
||||||
ssl->IOCB_ReadCtx = &ssl->rfd;
|
ssl->IOCB_ReadCtx = &ssl->rfd;
|
||||||
ssl->IOCB_WriteCtx = &ssl->wfd;
|
|
||||||
|
|
||||||
#ifdef WOLFSSL_DTLS
|
#ifdef WOLFSSL_DTLS
|
||||||
if (ssl->options.dtls) {
|
if (ssl->options.dtls) {
|
||||||
ssl->IOCB_ReadCtx = &ssl->buffers.dtlsCtx;
|
ssl->IOCB_ReadCtx = &ssl->buffers.dtlsCtx;
|
||||||
ssl->IOCB_WriteCtx = &ssl->buffers.dtlsCtx;
|
ssl->buffers.dtlsCtx.rfd = fd;
|
||||||
ssl->buffers.dtlsCtx.fd = fd;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
WOLFSSL_LEAVE("SSL_set_fd", SSL_SUCCESS);
|
WOLFSSL_LEAVE("SSL_set_read_fd", SSL_SUCCESS);
|
||||||
|
return SSL_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int wolfSSL_set_write_fd(WOLFSSL* ssl, int fd)
|
||||||
|
{
|
||||||
|
WOLFSSL_ENTER("SSL_set_write_fd");
|
||||||
|
|
||||||
|
if (ssl == NULL) {
|
||||||
|
return BAD_FUNC_ARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
ssl->wfd = fd; /* not used directly to allow IO callbacks */
|
||||||
|
ssl->IOCB_WriteCtx = &ssl->wfd;
|
||||||
|
|
||||||
|
#ifdef WOLFSSL_DTLS
|
||||||
|
if (ssl->options.dtls) {
|
||||||
|
ssl->IOCB_WriteCtx = &ssl->buffers.dtlsCtx;
|
||||||
|
ssl->buffers.dtlsCtx.wfd = fd;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
WOLFSSL_LEAVE("SSL_set_write_fd", SSL_SUCCESS);
|
||||||
return SSL_SUCCESS;
|
return SSL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1585,7 +1585,8 @@ struct WOLFSSL_SOCKADDR {
|
|||||||
|
|
||||||
typedef struct WOLFSSL_DTLS_CTX {
|
typedef struct WOLFSSL_DTLS_CTX {
|
||||||
WOLFSSL_SOCKADDR peer;
|
WOLFSSL_SOCKADDR peer;
|
||||||
int fd;
|
int rfd;
|
||||||
|
int wfd;
|
||||||
} WOLFSSL_DTLS_CTX;
|
} WOLFSSL_DTLS_CTX;
|
||||||
|
|
||||||
|
|
||||||
|
@@ -328,6 +328,8 @@ WOLFSSL_API int wolfSSL_use_RSAPrivateKey_file(WOLFSSL*, const char*, int);
|
|||||||
WOLFSSL_API WOLFSSL_CTX* wolfSSL_CTX_new(WOLFSSL_METHOD*);
|
WOLFSSL_API WOLFSSL_CTX* wolfSSL_CTX_new(WOLFSSL_METHOD*);
|
||||||
WOLFSSL_API WOLFSSL* wolfSSL_new(WOLFSSL_CTX*);
|
WOLFSSL_API WOLFSSL* wolfSSL_new(WOLFSSL_CTX*);
|
||||||
WOLFSSL_API int wolfSSL_set_fd (WOLFSSL*, int);
|
WOLFSSL_API int wolfSSL_set_fd (WOLFSSL*, int);
|
||||||
|
WOLFSSL_API int wolfSSL_set_write_fd (WOLFSSL*, int);
|
||||||
|
WOLFSSL_API int wolfSSL_set_read_fd (WOLFSSL*, int);
|
||||||
WOLFSSL_API char* wolfSSL_get_cipher_list(int priority);
|
WOLFSSL_API char* wolfSSL_get_cipher_list(int priority);
|
||||||
WOLFSSL_API int wolfSSL_get_ciphers(char*, int);
|
WOLFSSL_API int wolfSSL_get_ciphers(char*, int);
|
||||||
WOLFSSL_API const char* wolfSSL_get_cipher_name(WOLFSSL* ssl);
|
WOLFSSL_API const char* wolfSSL_get_cipher_name(WOLFSSL* ssl);
|
||||||
|
Reference in New Issue
Block a user