mirror of https://github.com/wolfSSL/wolfssl.git
moved and renamed the CBIO error codes so they are publically available
parent
d279695314
commit
fe13b4b6c6
|
@ -1791,18 +1791,6 @@ enum AlertDescription {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* I/O Callback default errors */
|
|
||||||
enum IOerrors {
|
|
||||||
IO_ERR_GENERAL = -1, /* general unexpected err, not in below group */
|
|
||||||
IO_ERR_WANT_READ = -2, /* need to call read again */
|
|
||||||
IO_ERR_WANT_WRITE = -2, /* need to call write again */
|
|
||||||
IO_ERR_CONN_RST = -3, /* connection reset */
|
|
||||||
IO_ERR_ISR = -4, /* interrupt */
|
|
||||||
IO_ERR_CONN_CLOSE = -5, /* connection closed or epipe */
|
|
||||||
IO_ERR_TIMEOUT = -6 /* socket timeout */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
enum AlertLevel {
|
enum AlertLevel {
|
||||||
alert_warning = 1,
|
alert_warning = 1,
|
||||||
alert_fatal = 2
|
alert_fatal = 2
|
||||||
|
|
12
cyassl/ssl.h
12
cyassl/ssl.h
|
@ -829,6 +829,18 @@ CYASSL_API void CyaSSL_SetIOOcspRespFree(CYASSL_CTX *ocsp,
|
||||||
CYASSL_API void CyaSSL_SetIOOcspCtx(CYASSL_CTX *ocsp, void *octx);
|
CYASSL_API void CyaSSL_SetIOOcspCtx(CYASSL_CTX *ocsp, void *octx);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* I/O Callback default errors */
|
||||||
|
enum IOerrors {
|
||||||
|
CYASSL_CBIO_ERR_GENERAL = -1, /* general unexpected err */
|
||||||
|
CYASSL_CBIO_ERR_WANT_READ = -2, /* need to call read again */
|
||||||
|
CYASSL_CBIO_ERR_WANT_WRITE = -2, /* need to call write again */
|
||||||
|
CYASSL_CBIO_ERR_CONN_RST = -3, /* connection reset */
|
||||||
|
CYASSL_CBIO_ERR_ISR = -4, /* interrupt */
|
||||||
|
CYASSL_CBIO_ERR_CONN_CLOSE = -5, /* connection closed or epipe */
|
||||||
|
CYASSL_CBIO_ERR_TIMEOUT = -6 /* socket timeout */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* CA cache callbacks */
|
/* CA cache callbacks */
|
||||||
enum {
|
enum {
|
||||||
CYASSL_SSLV3 = 0,
|
CYASSL_SSLV3 = 0,
|
||||||
|
|
|
@ -2245,13 +2245,13 @@ retry:
|
||||||
recvd = ssl->ctx->CBIORecv(ssl, (char *)buf, (int)sz, ssl->IOCB_ReadCtx);
|
recvd = ssl->ctx->CBIORecv(ssl, (char *)buf, (int)sz, ssl->IOCB_ReadCtx);
|
||||||
if (recvd < 0)
|
if (recvd < 0)
|
||||||
switch (recvd) {
|
switch (recvd) {
|
||||||
case IO_ERR_GENERAL: /* general/unknown error */
|
case CYASSL_CBIO_ERR_GENERAL: /* general/unknown error */
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
case IO_ERR_WANT_READ: /* want read, would block */
|
case CYASSL_CBIO_ERR_WANT_READ: /* want read, would block */
|
||||||
return WANT_READ;
|
return WANT_READ;
|
||||||
|
|
||||||
case IO_ERR_CONN_RST: /* connection reset */
|
case CYASSL_CBIO_ERR_CONN_RST: /* connection reset */
|
||||||
#ifdef USE_WINDOWS_API
|
#ifdef USE_WINDOWS_API
|
||||||
if (ssl->options.dtls) {
|
if (ssl->options.dtls) {
|
||||||
goto retry;
|
goto retry;
|
||||||
|
@ -2260,7 +2260,7 @@ retry:
|
||||||
ssl->options.connReset = 1;
|
ssl->options.connReset = 1;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
case IO_ERR_ISR: /* interrupt */
|
case CYASSL_CBIO_ERR_ISR: /* interrupt */
|
||||||
/* see if we got our timeout */
|
/* see if we got our timeout */
|
||||||
#ifdef CYASSL_CALLBACKS
|
#ifdef CYASSL_CALLBACKS
|
||||||
if (ssl->toInfoOn) {
|
if (ssl->toInfoOn) {
|
||||||
|
@ -2277,11 +2277,11 @@ retry:
|
||||||
#endif
|
#endif
|
||||||
goto retry;
|
goto retry;
|
||||||
|
|
||||||
case IO_ERR_CONN_CLOSE: /* peer closed connection */
|
case CYASSL_CBIO_ERR_CONN_CLOSE: /* peer closed connection */
|
||||||
ssl->options.isClosed = 1;
|
ssl->options.isClosed = 1;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
case IO_ERR_TIMEOUT:
|
case CYASSL_CBIO_ERR_TIMEOUT:
|
||||||
#ifdef CYASSL_DTLS
|
#ifdef CYASSL_DTLS
|
||||||
if (DtlsPoolTimeout(ssl) == 0 && DtlsPoolSend(ssl) == 0)
|
if (DtlsPoolTimeout(ssl) == 0 && DtlsPoolSend(ssl) == 0)
|
||||||
goto retry;
|
goto retry;
|
||||||
|
@ -2353,14 +2353,14 @@ int SendBuffered(CYASSL* ssl)
|
||||||
if (sent < 0) {
|
if (sent < 0) {
|
||||||
switch (sent) {
|
switch (sent) {
|
||||||
|
|
||||||
case IO_ERR_WANT_WRITE: /* would block */
|
case CYASSL_CBIO_ERR_WANT_WRITE: /* would block */
|
||||||
return WANT_WRITE;
|
return WANT_WRITE;
|
||||||
|
|
||||||
case IO_ERR_CONN_RST: /* connection reset */
|
case CYASSL_CBIO_ERR_CONN_RST: /* connection reset */
|
||||||
ssl->options.connReset = 1;
|
ssl->options.connReset = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IO_ERR_ISR: /* interrupt */
|
case CYASSL_CBIO_ERR_ISR: /* interrupt */
|
||||||
/* see if we got our timeout */
|
/* see if we got our timeout */
|
||||||
#ifdef CYASSL_CALLBACKS
|
#ifdef CYASSL_CALLBACKS
|
||||||
if (ssl->toInfoOn) {
|
if (ssl->toInfoOn) {
|
||||||
|
@ -2377,8 +2377,8 @@ int SendBuffered(CYASSL* ssl)
|
||||||
#endif
|
#endif
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case IO_ERR_CONN_CLOSE: /* epipe / conn closed, same as reset */
|
case CYASSL_CBIO_ERR_CONN_CLOSE: /* epipe / conn closed */
|
||||||
ssl->options.connReset = 1;
|
ssl->options.connReset = 1; /* treat same as reset */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
50
src/io.c
50
src/io.c
|
@ -217,37 +217,37 @@ int EmbedReceive(CYASSL *ssl, char *buf, int sz, void *ctx)
|
||||||
if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) {
|
if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) {
|
||||||
if (!CyaSSL_dtls(ssl) || CyaSSL_get_using_nonblock(ssl)) {
|
if (!CyaSSL_dtls(ssl) || CyaSSL_get_using_nonblock(ssl)) {
|
||||||
CYASSL_MSG(" Would block");
|
CYASSL_MSG(" Would block");
|
||||||
return IO_ERR_WANT_READ;
|
return CYASSL_CBIO_ERR_WANT_READ;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CYASSL_MSG(" Socket timeout");
|
CYASSL_MSG(" Socket timeout");
|
||||||
return IO_ERR_TIMEOUT;
|
return CYASSL_CBIO_ERR_TIMEOUT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (err == SOCKET_ECONNRESET) {
|
else if (err == SOCKET_ECONNRESET) {
|
||||||
CYASSL_MSG(" Connection reset");
|
CYASSL_MSG(" Connection reset");
|
||||||
return IO_ERR_CONN_RST;
|
return CYASSL_CBIO_ERR_CONN_RST;
|
||||||
}
|
}
|
||||||
else if (err == SOCKET_EINTR) {
|
else if (err == SOCKET_EINTR) {
|
||||||
CYASSL_MSG(" Socket interrupted");
|
CYASSL_MSG(" Socket interrupted");
|
||||||
return IO_ERR_ISR;
|
return CYASSL_CBIO_ERR_ISR;
|
||||||
}
|
}
|
||||||
else if (err == SOCKET_ECONNREFUSED) {
|
else if (err == SOCKET_ECONNREFUSED) {
|
||||||
CYASSL_MSG(" Connection refused");
|
CYASSL_MSG(" Connection refused");
|
||||||
return IO_ERR_WANT_READ;
|
return CYASSL_CBIO_ERR_WANT_READ;
|
||||||
}
|
}
|
||||||
else if (err == SOCKET_ECONNABORTED) {
|
else if (err == SOCKET_ECONNABORTED) {
|
||||||
CYASSL_MSG(" Connection aborted");
|
CYASSL_MSG(" Connection aborted");
|
||||||
return IO_ERR_CONN_CLOSE;
|
return CYASSL_CBIO_ERR_CONN_CLOSE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CYASSL_MSG(" General error");
|
CYASSL_MSG(" General error");
|
||||||
return IO_ERR_GENERAL;
|
return CYASSL_CBIO_ERR_GENERAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (recvd == 0) {
|
else if (recvd == 0) {
|
||||||
CYASSL_MSG("Embed receive connection closed");
|
CYASSL_MSG("Embed receive connection closed");
|
||||||
return IO_ERR_CONN_CLOSE;
|
return CYASSL_CBIO_ERR_CONN_CLOSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return recvd;
|
return recvd;
|
||||||
|
@ -271,23 +271,23 @@ int EmbedSend(CYASSL* ssl, char *buf, int sz, void *ctx)
|
||||||
|
|
||||||
if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) {
|
if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) {
|
||||||
CYASSL_MSG(" Would Block");
|
CYASSL_MSG(" Would Block");
|
||||||
return IO_ERR_WANT_WRITE;
|
return CYASSL_CBIO_ERR_WANT_WRITE;
|
||||||
}
|
}
|
||||||
else if (err == SOCKET_ECONNRESET) {
|
else if (err == SOCKET_ECONNRESET) {
|
||||||
CYASSL_MSG(" Connection reset");
|
CYASSL_MSG(" Connection reset");
|
||||||
return IO_ERR_CONN_RST;
|
return CYASSL_CBIO_ERR_CONN_RST;
|
||||||
}
|
}
|
||||||
else if (err == SOCKET_EINTR) {
|
else if (err == SOCKET_EINTR) {
|
||||||
CYASSL_MSG(" Socket interrupted");
|
CYASSL_MSG(" Socket interrupted");
|
||||||
return IO_ERR_ISR;
|
return CYASSL_CBIO_ERR_ISR;
|
||||||
}
|
}
|
||||||
else if (err == SOCKET_EPIPE) {
|
else if (err == SOCKET_EPIPE) {
|
||||||
CYASSL_MSG(" Socket EPIPE");
|
CYASSL_MSG(" Socket EPIPE");
|
||||||
return IO_ERR_CONN_CLOSE;
|
return CYASSL_CBIO_ERR_CONN_CLOSE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CYASSL_MSG(" General error");
|
CYASSL_MSG(" General error");
|
||||||
return IO_ERR_GENERAL;
|
return CYASSL_CBIO_ERR_GENERAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,28 +350,28 @@ int EmbedReceiveFrom(CYASSL *ssl, char *buf, int sz, void *ctx)
|
||||||
if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) {
|
if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) {
|
||||||
if (CyaSSL_get_using_nonblock(ssl)) {
|
if (CyaSSL_get_using_nonblock(ssl)) {
|
||||||
CYASSL_MSG(" Would block");
|
CYASSL_MSG(" Would block");
|
||||||
return IO_ERR_WANT_READ;
|
return CYASSL_CBIO_ERR_WANT_READ;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CYASSL_MSG(" Socket timeout");
|
CYASSL_MSG(" Socket timeout");
|
||||||
return IO_ERR_TIMEOUT;
|
return CYASSL_CBIO_ERR_TIMEOUT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (err == SOCKET_ECONNRESET) {
|
else if (err == SOCKET_ECONNRESET) {
|
||||||
CYASSL_MSG(" Connection reset");
|
CYASSL_MSG(" Connection reset");
|
||||||
return IO_ERR_CONN_RST;
|
return CYASSL_CBIO_ERR_CONN_RST;
|
||||||
}
|
}
|
||||||
else if (err == SOCKET_EINTR) {
|
else if (err == SOCKET_EINTR) {
|
||||||
CYASSL_MSG(" Socket interrupted");
|
CYASSL_MSG(" Socket interrupted");
|
||||||
return IO_ERR_ISR;
|
return CYASSL_CBIO_ERR_ISR;
|
||||||
}
|
}
|
||||||
else if (err == SOCKET_ECONNREFUSED) {
|
else if (err == SOCKET_ECONNREFUSED) {
|
||||||
CYASSL_MSG(" Connection refused");
|
CYASSL_MSG(" Connection refused");
|
||||||
return IO_ERR_WANT_READ;
|
return CYASSL_CBIO_ERR_WANT_READ;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CYASSL_MSG(" General error");
|
CYASSL_MSG(" General error");
|
||||||
return IO_ERR_GENERAL;
|
return CYASSL_CBIO_ERR_GENERAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -379,7 +379,7 @@ int EmbedReceiveFrom(CYASSL *ssl, char *buf, int sz, void *ctx)
|
||||||
&& peerSz != (XSOCKLENT)dtlsCtx->peer.sz
|
&& peerSz != (XSOCKLENT)dtlsCtx->peer.sz
|
||||||
&& memcmp(&peer, dtlsCtx->peer.sa, peerSz) != 0) {
|
&& memcmp(&peer, dtlsCtx->peer.sa, peerSz) != 0) {
|
||||||
CYASSL_MSG(" Ignored packet from invalid peer");
|
CYASSL_MSG(" Ignored packet from invalid peer");
|
||||||
return IO_ERR_WANT_READ;
|
return CYASSL_CBIO_ERR_WANT_READ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,23 +408,23 @@ int EmbedSendTo(CYASSL* ssl, char *buf, int sz, void *ctx)
|
||||||
|
|
||||||
if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) {
|
if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) {
|
||||||
CYASSL_MSG(" Would Block");
|
CYASSL_MSG(" Would Block");
|
||||||
return IO_ERR_WANT_WRITE;
|
return CYASSL_CBIO_ERR_WANT_WRITE;
|
||||||
}
|
}
|
||||||
else if (err == SOCKET_ECONNRESET) {
|
else if (err == SOCKET_ECONNRESET) {
|
||||||
CYASSL_MSG(" Connection reset");
|
CYASSL_MSG(" Connection reset");
|
||||||
return IO_ERR_CONN_RST;
|
return CYASSL_CBIO_ERR_CONN_RST;
|
||||||
}
|
}
|
||||||
else if (err == SOCKET_EINTR) {
|
else if (err == SOCKET_EINTR) {
|
||||||
CYASSL_MSG(" Socket interrupted");
|
CYASSL_MSG(" Socket interrupted");
|
||||||
return IO_ERR_ISR;
|
return CYASSL_CBIO_ERR_ISR;
|
||||||
}
|
}
|
||||||
else if (err == SOCKET_EPIPE) {
|
else if (err == SOCKET_EPIPE) {
|
||||||
CYASSL_MSG(" Socket EPIPE");
|
CYASSL_MSG(" Socket EPIPE");
|
||||||
return IO_ERR_CONN_CLOSE;
|
return CYASSL_CBIO_ERR_CONN_CLOSE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CYASSL_MSG(" General error");
|
CYASSL_MSG(" General error");
|
||||||
return IO_ERR_GENERAL;
|
return CYASSL_CBIO_ERR_GENERAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue