Ignore:
Timestamp:
Feb 7, 2019, 8:36:33 AM (5 years ago)
Author:
coas-nagasima
Message:

wolfsslを3.15.7にバージョンアップ

File:
1 edited

Legend:

Unmodified
Added
Removed
  • asp3_tinet_ecnl_rx/trunk/wolfssl-3.12.2/wolfssl/wolfio.h

    r337 r372  
    2020 */
    2121
     22/*!
     23    \file wolfssl/wolfio.h   
     24*/
    2225
    2326#ifndef WOLFSSL_IO_H
     
    2831#endif
    2932
     33/* Micrium uses NetSock I/O callbacks in wolfio.c */
     34#if !defined(WOLFSSL_USER_IO)
    3035/* OCSP and CRL_IO require HTTP client */
    3136#if defined(HAVE_OCSP) || defined(HAVE_CRL_IO)
     
    3439    #endif
    3540#endif
     41#endif
    3642
    3743#if !defined(WOLFSSL_USER_IO)
    3844    /* Micrium uses NetSock I/O callbacks in wolfio.c */
    39     #if !defined(USE_WOLFSSL_IO) && !defined(MICRIUM)
     45    #if !defined(USE_WOLFSSL_IO) && !defined(MICRIUM) && !defined(WOLFSSL_CONTIKI)
    4046        #define USE_WOLFSSL_IO
    4147    #endif
     
    5056
    5157#ifndef USE_WINDOWS_API
    52     #ifdef WOLFSSL_LWIP
     58    #if defined(WOLFSSL_LWIP) && !defined(WOLFSSL_APACHE_MYNEWT)
    5359        /* lwIP needs to be configured to use sockets API in this mode */
    5460        /* LWIP_SOCKET 1 in lwip/opt.h or in build */
    5561        #include "lwip/sockets.h"
    56         #include <errno.h>
    5762        #ifndef LWIP_PROVIDE_ERRNO
     63            #include <errno.h>
    5864            #define LWIP_PROVIDE_ERRNO 1
    5965        #endif
     
    6369    #elif defined(FREESCALE_KSDK_MQX)
    6470        #include <rtcs.h>
    65     #elif defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET)
    66         #if !defined(WOLFSSL_MDK_ARM)
     71    #elif (defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET))
    6772            #include "cmsis_os.h"
    6873            #include "rl_net.h"
    69         #else
    70             #include <rtl.h>
    71         #endif
    7274        #include "errno.h"
    73         #define SOCKET_T int
     75    #elif defined(WOLFSSL_CMSIS_RTOS)
     76        #include "cmsis_os.h"
    7477    #elif defined(WOLFSSL_TIRTOS)
    7578        #include <sys/socket.h>
     
    8083    #elif defined(WOLFSSL_VXWORKS)
    8184        #include <sockLib.h>
     85        #include <errno.h>
     86    #elif defined(WOLFSSL_NUCLEUS_1_2)
     87        #include <externs.h>
    8288        #include <errno.h>
    8389    #elif defined(WOLFSSL_ATMEL)
     
    105111    #elif defined(WOLFSSL_SGX)
    106112        #include <errno.h>
     113    #elif defined(WOLFSSL_APACHE_MYNEWT) && !defined(WOLFSSL_LWIP)
     114        #include <mn_socket/mn_socket.h>
    107115    #elif !defined(WOLFSSL_NO_SOCK)
    108116        #include <sys/types.h>
     
    118126            #include "rtipapi.h"  /* errno */
    119127            #include "socket.h"
    120         #elif !defined(DEVKITPRO) && !defined(WOLFSSL_PICOTCP)
     128        #elif !defined(DEVKITPRO) && !defined(WOLFSSL_PICOTCP) && !defined(WOLFSSL_CONTIKI)
    121129            #include <sys/socket.h>
    122130            #include <arpa/inet.h>
     
    148156    #define SOCKET_ECONNREFUSED WSAENOTCONN
    149157    #define SOCKET_ECONNABORTED WSAECONNABORTED
    150     #define close(s) closesocket(s)
    151158#elif defined(__PPU)
    152159    #define SOCKET_EWOULDBLOCK SYS_NET_EWOULDBLOCK
     
    177184    #endif
    178185#elif defined(WOLFSSL_MDK_ARM)|| defined(WOLFSSL_KEIL_TCP_NET)
    179     #if !defined(WOLFSSL_MDK_ARM)
    180186        #define SOCKET_EWOULDBLOCK BSD_ERROR_WOULDBLOCK
    181187        #define SOCKET_EAGAIN      BSD_ERROR_LOCKED
     
    185191        #define SOCKET_ECONNREFUSED BSD_ERROR
    186192        #define SOCKET_ECONNABORTED BSD_ERROR
    187     #else
    188         #define SOCKET_EWOULDBLOCK SCK_EWOULDBLOCK
    189         #define SOCKET_EAGAIN      SCK_ELOCKED
    190         #define SOCKET_ECONNRESET  SCK_ECLOSED
    191         #define SOCKET_EINTR       SCK_ERROR
    192         #define SOCKET_EPIPE       SCK_ERROR
    193         #define SOCKET_ECONNREFUSED SCK_ERROR
    194         #define SOCKET_ECONNABORTED SCK_ERROR
    195     #endif
    196193#elif defined(WOLFSSL_PICOTCP)
    197194    #define SOCKET_EWOULDBLOCK  PICO_ERR_EAGAIN
     
    210207    #define SOCKET_ECONNREFUSED FREERTOS_SOCKET_ERROR
    211208    #define SOCKET_ECONNABORTED FREERTOS_SOCKET_ERROR
     209#elif defined(WOLFSSL_NUCLEUS_1_2)
     210    #define SOCKET_EWOULDBLOCK  NU_WOULD_BLOCK
     211    #define SOCKET_EAGAIN       NU_WOULD_BLOCK
     212    #define SOCKET_ECONNRESET   NU_NOT_CONNECTED
     213    #define SOCKET_EINTR        NU_NOT_CONNECTED
     214    #define SOCKET_EPIPE        NU_NOT_CONNECTED
     215    #define SOCKET_ECONNREFUSED NU_CONNECTION_REFUSED
     216    #define SOCKET_ECONNABORTED NU_NOT_CONNECTED
    212217#else
    213218    #define SOCKET_EWOULDBLOCK EWOULDBLOCK
     
    221226
    222227
     228
     229
    223230#ifdef DEVKITPRO
    224231    /* from network.h */
     
    227234    #define SEND_FUNCTION net_send
    228235    #define RECV_FUNCTION net_recv
    229 #elif defined(WOLFSSL_LWIP)
     236#elif defined(WOLFSSL_LWIP) && !defined(WOLFSSL_APACHE_MYNEWT)
    230237    #define SEND_FUNCTION lwip_send
    231238    #define RECV_FUNCTION lwip_recv
     
    239246    #define SEND_FUNCTION send
    240247    #define RECV_FUNCTION recv
     248#elif defined(WOLFSSL_NUCLEUS_1_2)
     249    #define SEND_FUNCTION NU_Send
     250    #define RECV_FUNCTION NU_Recv
    241251#else
    242252    #define SEND_FUNCTION send
     
    273283    #endif /* HAVE_SOCKADDR */
    274284
     285    /* use gethostbyname for c99 */
     286    #ifdef WOLF_C99
     287        #undef HAVE_GETADDRINFO
     288    #endif
     289
    275290    #ifdef HAVE_GETADDRINFO
    276291        typedef struct addrinfo         ADDRINFO;
     
    282297#ifdef HAVE_IO_TIMEOUT
    283298    WOLFSSL_API  int wolfIO_SetBlockingMode(SOCKET_T sockfd, int non_blocking);
    284     WOLFSSL_API void wolfIO_SetTimeout(int to_sec);;
     299    WOLFSSL_API void wolfIO_SetTimeout(int to_sec);
    285300    WOLFSSL_API  int wolfIO_Select(SOCKET_T sockfd, int to_sec);
    286301#endif
     
    293308
    294309
     310#ifdef USE_WINDOWS_API
     311    #ifndef CloseSocket
     312        #define CloseSocket(s) closesocket(s)
     313    #endif
     314    #define StartTCP() { WSADATA wsd; WSAStartup(0x0002, &wsd); }
     315#elif defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET)
     316    #ifndef CloseSocket
     317        extern int closesocket(int);
     318        #define CloseSocket(s) closesocket(s)
     319    #endif
     320    #define StartTCP()
     321#else
     322    #ifndef CloseSocket
     323        #define CloseSocket(s) close(s)
     324    #endif
     325    #define StartTCP()
     326    #ifdef FREERTOS_TCP_WINSIM
     327        extern int close(int);
     328    #endif
     329#endif
     330
     331
     332WOLFSSL_API int BioSend(WOLFSSL* ssl, char *buf, int sz, void *ctx);
     333WOLFSSL_API int BioReceive(WOLFSSL* ssl, char* buf, int sz, void* ctx);
    295334#if defined(USE_WOLFSSL_IO)
    296335    /* default IO callbacks */
     
    346385        const char* domainName, const char* path, int pathLen, int reqSz,
    347386        const char* contentType, unsigned char* buf, int bufSize);
    348     WOLFSSL_API  int wolfIO_HttpProcessResponse(int sfd, const char* appStr,
     387    WOLFSSL_API  int wolfIO_HttpProcessResponse(int sfd, const char** appStrList,
    349388        unsigned char** respBuf, unsigned char* httpBuf, int httpBufSz,
    350389        int dynType, void* heap);
     
    355394typedef int (*CallbackIORecv)(WOLFSSL *ssl, char *buf, int sz, void *ctx);
    356395typedef int (*CallbackIOSend)(WOLFSSL *ssl, char *buf, int sz, void *ctx);
    357 WOLFSSL_API void wolfSSL_SetIORecv(WOLFSSL_CTX*, CallbackIORecv);
    358 WOLFSSL_API void wolfSSL_SetIOSend(WOLFSSL_CTX*, CallbackIOSend);
     396WOLFSSL_API void wolfSSL_CTX_SetIORecv(WOLFSSL_CTX*, CallbackIORecv);
     397WOLFSSL_API void wolfSSL_CTX_SetIOSend(WOLFSSL_CTX*, CallbackIOSend);
     398/* deprecated old name */
     399#define wolfSSL_SetIORecv wolfSSL_CTX_SetIORecv
     400#define wolfSSL_SetIOSend wolfSSL_CTX_SetIOSend
    359401
    360402WOLFSSL_API void wolfSSL_SetIOReadCtx( WOLFSSL* ssl, void *ctx);
     
    385427#endif /* MICRIUM */
    386428
     429#if defined(WOLFSSL_APACHE_MYNEWT) && !defined(WOLFSSL_LWIP)
     430    WOLFSSL_LOCAL int Mynewt_Receive(WOLFSSL *ssl, char *buf, int sz, void *ctx);
     431    WOLFSSL_LOCAL int Mynewt_Send(WOLFSSL* ssl, char *buf, int sz, void *ctx);
     432    WOLFSSL_API void wolfSSL_SetIO_Mynewt(WOLFSSL* ssl, struct mn_socket* mnSocket,
     433                                          struct mn_sockaddr_in* mnSockAddrIn);
     434#endif /* defined(WOLFSSL_APACHE_MYNEWT) && !defined(WOLFSSL_LWIP) */
     435
     436#ifdef WOLFSSL_UIP
     437
     438    struct uip_wolfssl_ctx {
     439        union socket_connector {
     440            struct tcp_socket tcp;
     441            struct udp_socket udp;
     442        } conn;
     443        WOLFSSL_CTX *ctx;
     444        WOLFSSL *ssl;
     445        uint8_t *input_databuf;
     446        uint8_t *output_databuf;
     447        uint8_t *ssl_rx_databuf;
     448        int ssl_rb_len;
     449        int ssl_rb_off;
     450        struct process *process;
     451        tcp_socket_data_callback_t input_callback;
     452        tcp_socket_event_callback_t event_callback;
     453        int closing;
     454        uip_ipaddr_t peer_addr;
     455        uint16_t peer_port;
     456    };
     457
     458    typedef struct uip_wolfssl_ctx uip_wolfssl_ctx;
     459
     460    WOLFSSL_LOCAL int uIPSend(WOLFSSL* ssl, char* buf, int sz, void* ctx);
     461    WOLFSSL_LOCAL int uIPReceive(WOLFSSL* ssl, char* buf, int sz,
     462                                     void* ctx);
     463    WOLFSSL_LOCAL int uIPReceiveFrom(WOLFSSL* ssl, char* buf, int sz,
     464                                         void* ctx);
     465    WOLFSSL_LOCAL int uIPSendTo(WOLFSSL* ssl, char* buf, int sz, void* ctx);
     466
     467#endif
     468
    387469#ifdef WOLFSSL_DTLS
    388470    typedef int (*CallbackGenCookie)(WOLFSSL* ssl, unsigned char* buf, int sz,
     
    407489#ifndef XINET_NTOP
    408490    #define XINET_NTOP(a,b,c,d) inet_ntop((a),(b),(c),(d))
     491    #ifdef USE_WINDOWS_API /* Windows-friendly definition */
     492        #undef  XINET_NTOP
     493        #define XINET_NTOP(a,b,c,d) InetNtop((a),(b),(c),(d))
     494    #endif
    409495#endif
    410496#ifndef XINET_PTON
    411497    #define XINET_PTON(a,b,c)   inet_pton((a),(b),(c))
     498    #ifdef USE_WINDOWS_API /* Windows-friendly definition */
     499        #undef  XINET_PTON
     500        #define XINET_PTON(a,b,c)   InetPton((a),(b),(c))
     501    #endif
    412502#endif
    413503#ifndef XHTONS
Note: See TracChangeset for help on using the changeset viewer.