mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
Check-in Nucleus Plus 2.3 port work
This commit is contained in:
111
src/wolfio.c
111
src/wolfio.c
@ -41,6 +41,11 @@
|
||||
#include <wolfssl/error-ssl.h>
|
||||
#include <wolfssl/wolfio.h>
|
||||
|
||||
#ifdef NUCLEUS_PLUS_2_3
|
||||
/* Holds last Nucleus networking error number */
|
||||
int Nucleus_Net_Errno;
|
||||
#endif
|
||||
|
||||
#if defined(USE_WOLFSSL_IO) || defined(HAVE_HTTP_CLIENT)
|
||||
#ifndef USE_WINDOWS_API
|
||||
#if defined(WOLFSSL_LWIP) && !defined(WOLFSSL_APACHE_MYNEWT)
|
||||
@ -176,6 +181,8 @@ static WC_INLINE int wolfSSL_LastError(int err)
|
||||
#elif defined(FUSION_RTOS)
|
||||
#include <fclerrno.h>
|
||||
return FCL_GET_ERRNO;
|
||||
#elif defined(NUCLEUS_PLUS_2_3)
|
||||
return Nucleus_Net_Errno;
|
||||
#else
|
||||
return errno;
|
||||
#endif
|
||||
@ -411,6 +418,110 @@ int EmbedSend(WOLFSSL* ssl, char *buf, int sz, void *ctx)
|
||||
|
||||
#include <wolfssl/wolfcrypt/sha.h>
|
||||
|
||||
#if defined(NUCLEUS_PLUS_2_3)
|
||||
STATIC INT32 nucyassl_recv(INT sd, CHAR *buf, UINT16 sz, INT16 flags)
|
||||
{
|
||||
int recvd;
|
||||
|
||||
/* Read data from socket */
|
||||
recvd = NU_Recv(sd, buf, sz, flags);
|
||||
if (recvd < 0) {
|
||||
if (recvd == NU_NOT_CONNECTED) {
|
||||
recvd = 0;
|
||||
} else {
|
||||
Nucleus_Net_Errno = recvd;
|
||||
recvd = WOLFSSL_FATAL_ERROR;
|
||||
}
|
||||
} else {
|
||||
Nucleus_Net_Errno = 0;
|
||||
}
|
||||
|
||||
return (recvd);
|
||||
}
|
||||
|
||||
|
||||
STATIC int nucyassl_send(INT sd, CHAR *buf, UINT16 sz, INT16 flags)
|
||||
{
|
||||
int sent;
|
||||
|
||||
/* Write data to socket */
|
||||
sent = NU_Send(sd, buf, sz, flags);
|
||||
|
||||
if (sent < 0) {
|
||||
Nucleus_Net_Errno = sent;
|
||||
sent = WOLFSSL_FATAL_ERROR;
|
||||
} else {
|
||||
Nucleus_Net_Errno = 0;
|
||||
}
|
||||
|
||||
return sent;
|
||||
}
|
||||
|
||||
#define SELECT_FUNCTION nucyassl_select
|
||||
|
||||
int nucyassl_select(INT sd, UINT32 timeout)
|
||||
{
|
||||
FD_SET readfs;
|
||||
STATUS status;
|
||||
|
||||
/* Init fs data for socket */
|
||||
NU_FD_Init(&readfs);
|
||||
NU_FD_Set(sd, &readfs);
|
||||
|
||||
/* Wait for data to arrive */
|
||||
status = NU_Select((sd + 1), &readfs, NU_NULL, NU_NULL,
|
||||
(timeout * NU_TICKS_PER_SECOND));
|
||||
|
||||
if (status < 0) {
|
||||
Nucleus_Net_Errno = status;
|
||||
status = WOLFSSL_FATAL_ERROR;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
#define sockaddr_storage addr_struct
|
||||
#define sockaddr addr_struct
|
||||
|
||||
STATIC INT32 nucyassl_recvfrom(INT sd, CHAR *buf, UINT16 sz, INT16 flags,
|
||||
SOCKADDR *peer, XSOCKLENT *peersz)
|
||||
{
|
||||
int recvd;
|
||||
|
||||
memset(peer, 0, sizeof(struct addr_struct));
|
||||
|
||||
recvd = NU_Recv_From(sd, buf, sz, flags, (struct addr_struct *) peer,
|
||||
(INT16*) peersz);
|
||||
if (recvd < 0) {
|
||||
Nucleus_Net_Errno = recvd;
|
||||
recvd = WOLFSSL_FATAL_ERROR;
|
||||
} else {
|
||||
Nucleus_Net_Errno = 0;
|
||||
}
|
||||
|
||||
return recvd;
|
||||
|
||||
}
|
||||
|
||||
STATIC int nucyassl_sendto(INT sd, CHAR *buf, UINT16 sz, INT16 flags,
|
||||
const SOCKADDR *peer, INT16 peersz)
|
||||
{
|
||||
int sent;
|
||||
|
||||
sent = NU_Send_To(sd, buf, sz, flags, (const struct addr_struct *) peer,
|
||||
peersz);
|
||||
|
||||
if (sent < 0) {
|
||||
Nucleus_Net_Errno = sent;
|
||||
sent = WOLFSSL_FATAL_ERROR;
|
||||
} else {
|
||||
Nucleus_Net_Errno = 0;
|
||||
}
|
||||
|
||||
return sent;
|
||||
}
|
||||
#endif /* NUCLEUS_PLUS_2_3 */
|
||||
|
||||
#ifndef DTLS_SENDTO_FUNCTION
|
||||
#define DTLS_SENDTO_FUNCTION sendto
|
||||
#endif
|
||||
|
@ -441,7 +441,7 @@ static WC_INLINE void AddLength(wc_Sha* sha, word32 len)
|
||||
#define f3(x,y,z) (((x)&(y))|((z)&((x)|(y))))
|
||||
#define f4(x,y,z) ((x)^(y)^(z))
|
||||
|
||||
#ifdef WOLFSSL_NUCLEUS_1_2
|
||||
#if defined(WOLFSSL_NUCLEUS_1_2) || defined(NUCLEUS_PLUS_2_3)
|
||||
/* nucleus.h also defines R1-R4 */
|
||||
#undef R1
|
||||
#undef R2
|
||||
|
@ -3089,6 +3089,8 @@ WOLFSSL_API int wolfSSL_make_eap_keys(WOLFSSL* ssl, void* key, unsigned int len,
|
||||
#include <sys/socket.h>
|
||||
#elif defined(ARDUINO)
|
||||
/* TODO board specific */
|
||||
#elif defined(NUCLEUS_PLUS_2_3)
|
||||
#include "services/sys/uio.h"
|
||||
#elif !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_IAR_ARM) && \
|
||||
!defined(WOLFSSL_PICOTCP) && !defined(WOLFSSL_ROWLEY_ARM) && \
|
||||
!defined(WOLFSSL_EMBOS) && !defined(WOLFSSL_FROSTED) && \
|
||||
|
@ -114,6 +114,13 @@ WOLFSSL_API int wc_RunCast_fips(int type);
|
||||
WOLFSSL_API int wc_GetCastStatus_fips(int type);
|
||||
WOLFSSL_API int wc_RunAllCast_fips(void);
|
||||
|
||||
#ifdef NO_ATTRIBUTE_CONSTRUCTOR
|
||||
/* NOTE: Must be called in OS initialization section outside user control
|
||||
* and must prove during operational testing/code review with the lab that
|
||||
* this is outside user-control if called by the OS */
|
||||
void fipsEntry(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
@ -212,6 +212,9 @@
|
||||
/* Uncomment next line if building for Nucleus 1.2 */
|
||||
/* #define WOLFSSL_NUCLEUS_1_2 */
|
||||
|
||||
/* Uncomment next line if building for Nucleus Plus 2.3 */
|
||||
/* #define NUCLEUS_PLUS_2_3 */
|
||||
|
||||
/* Uncomment next line if building for using Apache mynewt */
|
||||
/* #define WOLFSSL_APACHE_MYNEWT */
|
||||
|
||||
@ -319,6 +322,10 @@
|
||||
#elif defined(USE_HAL_DRIVER) && !defined(HAVE_CONFIG_H)
|
||||
/* STM Configuration File (generated by CubeMX) */
|
||||
#include "wolfSSL.I-CUBE-wolfSSL_conf.h"
|
||||
#elif defined(NUCLEUS_PLUS_2_3)
|
||||
/* NOTE: cyassl_nucleus_defs.h is akin to user_settings.h */
|
||||
#include "nucleus.h"
|
||||
#include "os/networking/ssl/lite/cyassl_nucleus_defs.h"
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/visibility.h>
|
||||
|
@ -168,6 +168,9 @@
|
||||
#include "socket.h"
|
||||
#elif defined(NETOS)
|
||||
#include <sockapi.h>
|
||||
#elif defined(NUCLEUS_PLUS_2_3)
|
||||
#define SO_TYPE 17 /* Socket type */
|
||||
#define SO_RCVTIMEO 13 /* Recv Timeout */
|
||||
#elif !defined(DEVKITPRO) && !defined(WOLFSSL_PICOTCP) \
|
||||
&& !defined(WOLFSSL_CONTIKI) && !defined(WOLFSSL_WICED) \
|
||||
&& !defined(WOLFSSL_GNRC) && !defined(WOLFSSL_RIOT_OS)
|
||||
@ -270,6 +273,14 @@
|
||||
#define SOCKET_EPIPE NU_NOT_CONNECTED
|
||||
#define SOCKET_ECONNREFUSED NU_CONNECTION_REFUSED
|
||||
#define SOCKET_ECONNABORTED NU_NOT_CONNECTED
|
||||
#elif defined(NUCLEUS_PLUS_2_3)
|
||||
#define SOCKET_EWOULDBLOCK NU_WOULD_BLOCK
|
||||
#define SOCKET_EAGAIN NU_NO_DATA
|
||||
#define SOCKET_ECONNRESET NU_RESET
|
||||
#define SOCKET_EINTR 0
|
||||
#define SOCKET_EPIPE 0
|
||||
#define SOCKET_ECONNREFUSED NU_CONNECTION_REFUSED
|
||||
#define SOCKET_ECONNABORTED NU_CONNECTION_REFUSED
|
||||
#elif defined(WOLFSSL_DEOS)
|
||||
/* `sockaddr_storage` is not defined in DEOS. This workaround will
|
||||
* work for IPV4, but not IPV6
|
||||
@ -354,6 +365,11 @@
|
||||
#elif defined(WOLFSSL_NUCLEUS_1_2)
|
||||
#define SEND_FUNCTION NU_Send
|
||||
#define RECV_FUNCTION NU_Recv
|
||||
#elif defined(NUCLEUS_PLUS_2_3)
|
||||
#define SEND_FUNCTION nucyassl_send
|
||||
#define RECV_FUNCTION nucyassl_recv
|
||||
#define DTLS_RECVFROM_FUNCTION nucyassl_recvfrom
|
||||
#define DTLS_SENDTO_FUNCTION nucyassl_sendto
|
||||
#elif defined(FUSION_RTOS)
|
||||
#define SEND_FUNCTION FNS_SEND
|
||||
#define RECV_FUNCTION FNS_RECV
|
||||
@ -398,6 +414,9 @@
|
||||
#ifndef XSOCKLENT
|
||||
#ifdef USE_WINDOWS_API
|
||||
#define XSOCKLENT int
|
||||
#elif defined(NUCLEUS_PLUS_2_3)
|
||||
typedef int socklen_t;
|
||||
#define XSOCKLENT socklen_t
|
||||
#else
|
||||
#define XSOCKLENT socklen_t
|
||||
#endif
|
||||
@ -485,6 +504,10 @@ WOLFSSL_API int BioReceive(WOLFSSL* ssl, char* buf, int sz, void* ctx);
|
||||
WOLFSSL_API int EmbedSend(WOLFSSL* ssl, char* buf, int sz, void* ctx);
|
||||
|
||||
#ifdef WOLFSSL_DTLS
|
||||
#ifdef NUCLEUS_PLUS_2_3
|
||||
#define SELECT_FUNCTION nucyassl_select
|
||||
WOLFSSL_LOCAL int nucyassl_select(INT sd, UINT32 timeout);
|
||||
#endif
|
||||
WOLFSSL_API int EmbedReceiveFrom(WOLFSSL *ssl, char *buf, int sz,
|
||||
void *ctx);
|
||||
WOLFSSL_API int EmbedSendTo(WOLFSSL* ssl, char *buf, int sz, void *ctx);
|
||||
|
Reference in New Issue
Block a user