mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-01 19:54:40 +02:00
Merge pull request #645 from toddouska/fds
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_max = DTLS_TIMEOUT_MAX;
|
||||
ssl->dtls_timeout = ssl->dtls_timeout_init;
|
||||
ssl->buffers.dtlsCtx.fd = -1;
|
||||
ssl->buffers.dtlsCtx.rfd = -1;
|
||||
ssl->buffers.dtlsCtx.wfd = -1;
|
||||
#endif
|
||||
|
||||
#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;
|
||||
int recvd;
|
||||
int err;
|
||||
int sd = dtlsCtx->fd;
|
||||
int sd = dtlsCtx->rfd;
|
||||
int dtls_timeout = wolfSSL_dtls_get_current_timeout(ssl);
|
||||
struct sockaddr_storage 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)
|
||||
{
|
||||
WOLFSSL_DTLS_CTX* dtlsCtx = (WOLFSSL_DTLS_CTX*)ctx;
|
||||
int sd = dtlsCtx->fd;
|
||||
int sd = dtlsCtx->wfd;
|
||||
int sent;
|
||||
int len = sz;
|
||||
int err;
|
||||
|
47
src/ssl.c
47
src/ssl.c
@@ -431,29 +431,64 @@ int wolfSSL_use_old_poly(WOLFSSL* ssl, int value)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int wolfSSL_set_fd(WOLFSSL* ssl, int fd)
|
||||
{
|
||||
int ret;
|
||||
|
||||
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) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
ssl->rfd = fd; /* not used directly to allow IO callbacks */
|
||||
ssl->wfd = fd;
|
||||
|
||||
ssl->IOCB_ReadCtx = &ssl->rfd;
|
||||
ssl->IOCB_WriteCtx = &ssl->wfd;
|
||||
|
||||
#ifdef WOLFSSL_DTLS
|
||||
if (ssl->options.dtls) {
|
||||
ssl->IOCB_ReadCtx = &ssl->buffers.dtlsCtx;
|
||||
ssl->IOCB_WriteCtx = &ssl->buffers.dtlsCtx;
|
||||
ssl->buffers.dtlsCtx.fd = fd;
|
||||
ssl->buffers.dtlsCtx.rfd = fd;
|
||||
}
|
||||
#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;
|
||||
}
|
||||
|
||||
|
@@ -1585,7 +1585,8 @@ struct WOLFSSL_SOCKADDR {
|
||||
|
||||
typedef struct WOLFSSL_DTLS_CTX {
|
||||
WOLFSSL_SOCKADDR peer;
|
||||
int fd;
|
||||
int rfd;
|
||||
int wfd;
|
||||
} 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* wolfSSL_new(WOLFSSL_CTX*);
|
||||
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 int wolfSSL_get_ciphers(char*, int);
|
||||
WOLFSSL_API const char* wolfSSL_get_cipher_name(WOLFSSL* ssl);
|
||||
|
Reference in New Issue
Block a user