mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 20:24:39 +02:00
add user ability to set IO read/write flags
This commit is contained in:
@@ -1272,6 +1272,8 @@ struct CYASSL {
|
|||||||
Keys keys;
|
Keys keys;
|
||||||
int rfd; /* read file descriptor */
|
int rfd; /* read file descriptor */
|
||||||
int wfd; /* write file descriptor */
|
int wfd; /* write file descriptor */
|
||||||
|
int rflags; /* user read flags */
|
||||||
|
int wflags; /* user write flags */
|
||||||
CYASSL_BIO* biord; /* socket bio read to free/close */
|
CYASSL_BIO* biord; /* socket bio read to free/close */
|
||||||
CYASSL_BIO* biowr; /* socket bio write to free/close */
|
CYASSL_BIO* biowr; /* socket bio write to free/close */
|
||||||
void* IOCB_ReadCtx;
|
void* IOCB_ReadCtx;
|
||||||
|
@@ -781,6 +781,9 @@ CYASSL_API void CyaSSL_SetIOSend(CYASSL_CTX*, CallbackIOSend);
|
|||||||
CYASSL_API void CyaSSL_SetIOReadCtx( CYASSL* ssl, void *ctx);
|
CYASSL_API void CyaSSL_SetIOReadCtx( CYASSL* ssl, void *ctx);
|
||||||
CYASSL_API void CyaSSL_SetIOWriteCtx(CYASSL* ssl, void *ctx);
|
CYASSL_API void CyaSSL_SetIOWriteCtx(CYASSL* ssl, void *ctx);
|
||||||
|
|
||||||
|
CYASSL_API void CyaSSL_SetIOReadFlags( CYASSL* ssl, int flags);
|
||||||
|
CYASSL_API void CyaSSL_SetIOWriteFlags(CYASSL* ssl, int flags);
|
||||||
|
|
||||||
/* CA cache callbacks */
|
/* CA cache callbacks */
|
||||||
enum {
|
enum {
|
||||||
CYASSL_SSLV3 = 0,
|
CYASSL_SSLV3 = 0,
|
||||||
|
@@ -970,10 +970,12 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx)
|
|||||||
ssl->timeout = ctx->timeout;
|
ssl->timeout = ctx->timeout;
|
||||||
ssl->rfd = -1; /* set to invalid descriptor */
|
ssl->rfd = -1; /* set to invalid descriptor */
|
||||||
ssl->wfd = -1;
|
ssl->wfd = -1;
|
||||||
|
ssl->rflags = 0; /* no user flags yet */
|
||||||
|
ssl->wflags = 0; /* no user flags yet */
|
||||||
ssl->biord = 0;
|
ssl->biord = 0;
|
||||||
ssl->biowr = 0;
|
ssl->biowr = 0;
|
||||||
|
|
||||||
ssl->IOCB_ReadCtx = &ssl->rfd; /* prevent invalid pointer acess if not */
|
ssl->IOCB_ReadCtx = &ssl->rfd; /* prevent invalid pointer access if not */
|
||||||
ssl->IOCB_WriteCtx = &ssl->wfd; /* correctly set */
|
ssl->IOCB_WriteCtx = &ssl->wfd; /* correctly set */
|
||||||
|
|
||||||
InitMd5(&ssl->hashMd5);
|
InitMd5(&ssl->hashMd5);
|
||||||
|
25
src/io.c
25
src/io.c
@@ -160,7 +160,7 @@ int EmbedReceive(CYASSL *ssl, char *buf, int sz, void *ctx)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
recvd = (int)RECV_FUNCTION(sd, (char *)buf, sz, 0);
|
recvd = (int)RECV_FUNCTION(sd, buf, sz, ssl->rflags);
|
||||||
|
|
||||||
if (recvd < 0) {
|
if (recvd < 0) {
|
||||||
err = LastError();
|
err = LastError();
|
||||||
@@ -211,9 +211,7 @@ int EmbedSend(CYASSL* ssl, char *buf, int sz, void *ctx)
|
|||||||
int len = sz;
|
int len = sz;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
(void)ssl;
|
sent = (int)SEND_FUNCTION(sd, &buf[sz - len], len, ssl->wflags);
|
||||||
|
|
||||||
sent = (int)SEND_FUNCTION(sd, &buf[sz - len], len, 0);
|
|
||||||
|
|
||||||
if (sent < 0) {
|
if (sent < 0) {
|
||||||
err = LastError();
|
err = LastError();
|
||||||
@@ -283,7 +281,7 @@ int EmbedReceiveFrom(CYASSL *ssl, char *buf, int sz, void *ctx)
|
|||||||
(char*)&timeout, sizeof(timeout));
|
(char*)&timeout, sizeof(timeout));
|
||||||
}
|
}
|
||||||
|
|
||||||
recvd = (int)RECVFROM_FUNCTION(sd, (char *)buf, sz, 0,
|
recvd = (int)RECVFROM_FUNCTION(sd, buf, sz, ssl->rflags,
|
||||||
(struct sockaddr*)&peer, &peerSz);
|
(struct sockaddr*)&peer, &peerSz);
|
||||||
|
|
||||||
if (recvd < 0) {
|
if (recvd < 0) {
|
||||||
@@ -342,12 +340,9 @@ int EmbedSendTo(CYASSL* ssl, char *buf, int sz, void *ctx)
|
|||||||
int len = sz;
|
int len = sz;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
(void)ssl;
|
|
||||||
|
|
||||||
CYASSL_ENTER("EmbedSendTo()");
|
CYASSL_ENTER("EmbedSendTo()");
|
||||||
sent = (int)SENDTO_FUNCTION(sd, &buf[sz - len], len, 0,
|
sent = (int)SENDTO_FUNCTION(sd, &buf[sz - len], len, ssl->wflags,
|
||||||
dtlsCtx->peer.sa, dtlsCtx->peer.sz);
|
dtlsCtx->peer.sa, dtlsCtx->peer.sz);
|
||||||
|
|
||||||
if (sent < 0) {
|
if (sent < 0) {
|
||||||
err = LastError();
|
err = LastError();
|
||||||
CYASSL_MSG("Embed Send To error");
|
CYASSL_MSG("Embed Send To error");
|
||||||
@@ -445,3 +440,15 @@ CYASSL_API void CyaSSL_SetIOWriteCtx(CYASSL* ssl, void *wctx)
|
|||||||
ssl->IOCB_WriteCtx = wctx;
|
ssl->IOCB_WriteCtx = wctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CYASSL_API void CyaSSL_SetIOReadFlags(CYASSL* ssl, int flags)
|
||||||
|
{
|
||||||
|
ssl->rflags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CYASSL_API void CyaSSL_SetIOWriteFlags(CYASSL* ssl, int flags)
|
||||||
|
{
|
||||||
|
ssl->wflags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user