Changeset 372 for asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfio.h
- Timestamp:
- Feb 7, 2019, 8:36:33 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfio.h
r352 r372 20 20 */ 21 21 22 /*! 23 \file wolfssl/wolfio.h 24 */ 22 25 23 26 #ifndef WOLFSSL_IO_H … … 28 31 #endif 29 32 33 /* Micrium uses NetSock I/O callbacks in wolfio.c */ 34 #if !defined(WOLFSSL_USER_IO) 30 35 /* OCSP and CRL_IO require HTTP client */ 31 36 #if defined(HAVE_OCSP) || defined(HAVE_CRL_IO) … … 34 39 #endif 35 40 #endif 41 #endif 36 42 37 43 #if !defined(WOLFSSL_USER_IO) 38 44 /* 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) 40 46 #define USE_WOLFSSL_IO 41 47 #endif … … 50 56 51 57 #ifndef USE_WINDOWS_API 52 #if def WOLFSSL_LWIP58 #if defined(WOLFSSL_LWIP) && !defined(WOLFSSL_APACHE_MYNEWT) 53 59 /* lwIP needs to be configured to use sockets API in this mode */ 54 60 /* LWIP_SOCKET 1 in lwip/opt.h or in build */ 55 61 #include "lwip/sockets.h" 56 #include <errno.h>57 62 #ifndef LWIP_PROVIDE_ERRNO 63 #include <errno.h> 58 64 #define LWIP_PROVIDE_ERRNO 1 59 65 #endif … … 63 69 #elif defined(FREESCALE_KSDK_MQX) 64 70 #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)) 67 72 #include "cmsis_os.h" 68 73 #include "rl_net.h" 69 #else70 #include <rtl.h>71 #endif72 74 #include "errno.h" 73 #define SOCKET_T int 75 #elif defined(WOLFSSL_CMSIS_RTOS) 76 #include "cmsis_os.h" 74 77 #elif defined(WOLFSSL_TIRTOS) 75 78 #include <sys/socket.h> … … 80 83 #elif defined(WOLFSSL_VXWORKS) 81 84 #include <sockLib.h> 85 #include <errno.h> 86 #elif defined(WOLFSSL_NUCLEUS_1_2) 87 #include <externs.h> 82 88 #include <errno.h> 83 89 #elif defined(WOLFSSL_ATMEL) … … 105 111 #elif defined(WOLFSSL_SGX) 106 112 #include <errno.h> 113 #elif defined(WOLFSSL_APACHE_MYNEWT) && !defined(WOLFSSL_LWIP) 114 #include <mn_socket/mn_socket.h> 107 115 #elif !defined(WOLFSSL_NO_SOCK) 108 116 #include <sys/types.h> … … 118 126 #include "rtipapi.h" /* errno */ 119 127 #include "socket.h" 120 #elif !defined(DEVKITPRO) && !defined(WOLFSSL_PICOTCP) 128 #elif !defined(DEVKITPRO) && !defined(WOLFSSL_PICOTCP) && !defined(WOLFSSL_CONTIKI) 121 129 #include <sys/socket.h> 122 130 #include <arpa/inet.h> … … 148 156 #define SOCKET_ECONNREFUSED WSAENOTCONN 149 157 #define SOCKET_ECONNABORTED WSAECONNABORTED 150 #define close(s) closesocket(s)151 158 #elif defined(__PPU) 152 159 #define SOCKET_EWOULDBLOCK SYS_NET_EWOULDBLOCK … … 177 184 #endif 178 185 #elif defined(WOLFSSL_MDK_ARM)|| defined(WOLFSSL_KEIL_TCP_NET) 179 #if !defined(WOLFSSL_MDK_ARM)180 186 #define SOCKET_EWOULDBLOCK BSD_ERROR_WOULDBLOCK 181 187 #define SOCKET_EAGAIN BSD_ERROR_LOCKED … … 185 191 #define SOCKET_ECONNREFUSED BSD_ERROR 186 192 #define SOCKET_ECONNABORTED BSD_ERROR 187 #else188 #define SOCKET_EWOULDBLOCK SCK_EWOULDBLOCK189 #define SOCKET_EAGAIN SCK_ELOCKED190 #define SOCKET_ECONNRESET SCK_ECLOSED191 #define SOCKET_EINTR SCK_ERROR192 #define SOCKET_EPIPE SCK_ERROR193 #define SOCKET_ECONNREFUSED SCK_ERROR194 #define SOCKET_ECONNABORTED SCK_ERROR195 #endif196 193 #elif defined(WOLFSSL_PICOTCP) 197 194 #define SOCKET_EWOULDBLOCK PICO_ERR_EAGAIN … … 210 207 #define SOCKET_ECONNREFUSED FREERTOS_SOCKET_ERROR 211 208 #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 212 217 #else 213 218 #define SOCKET_EWOULDBLOCK EWOULDBLOCK … … 221 226 222 227 228 229 223 230 #ifdef DEVKITPRO 224 231 /* from network.h */ … … 227 234 #define SEND_FUNCTION net_send 228 235 #define RECV_FUNCTION net_recv 229 #elif defined(WOLFSSL_LWIP) 236 #elif defined(WOLFSSL_LWIP) && !defined(WOLFSSL_APACHE_MYNEWT) 230 237 #define SEND_FUNCTION lwip_send 231 238 #define RECV_FUNCTION lwip_recv … … 239 246 #define SEND_FUNCTION send 240 247 #define RECV_FUNCTION recv 248 #elif defined(WOLFSSL_NUCLEUS_1_2) 249 #define SEND_FUNCTION NU_Send 250 #define RECV_FUNCTION NU_Recv 241 251 #else 242 252 #define SEND_FUNCTION send … … 273 283 #endif /* HAVE_SOCKADDR */ 274 284 285 /* use gethostbyname for c99 */ 286 #ifdef WOLF_C99 287 #undef HAVE_GETADDRINFO 288 #endif 289 275 290 #ifdef HAVE_GETADDRINFO 276 291 typedef struct addrinfo ADDRINFO; … … 282 297 #ifdef HAVE_IO_TIMEOUT 283 298 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); 285 300 WOLFSSL_API int wolfIO_Select(SOCKET_T sockfd, int to_sec); 286 301 #endif … … 293 308 294 309 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 332 WOLFSSL_API int BioSend(WOLFSSL* ssl, char *buf, int sz, void *ctx); 333 WOLFSSL_API int BioReceive(WOLFSSL* ssl, char* buf, int sz, void* ctx); 295 334 #if defined(USE_WOLFSSL_IO) 296 335 /* default IO callbacks */ … … 346 385 const char* domainName, const char* path, int pathLen, int reqSz, 347 386 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, 349 388 unsigned char** respBuf, unsigned char* httpBuf, int httpBufSz, 350 389 int dynType, void* heap); … … 355 394 typedef int (*CallbackIORecv)(WOLFSSL *ssl, char *buf, int sz, void *ctx); 356 395 typedef 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); 396 WOLFSSL_API void wolfSSL_CTX_SetIORecv(WOLFSSL_CTX*, CallbackIORecv); 397 WOLFSSL_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 359 401 360 402 WOLFSSL_API void wolfSSL_SetIOReadCtx( WOLFSSL* ssl, void *ctx); … … 385 427 #endif /* MICRIUM */ 386 428 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 387 469 #ifdef WOLFSSL_DTLS 388 470 typedef int (*CallbackGenCookie)(WOLFSSL* ssl, unsigned char* buf, int sz, … … 407 489 #ifndef XINET_NTOP 408 490 #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 409 495 #endif 410 496 #ifndef XINET_PTON 411 497 #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 412 502 #endif 413 503 #ifndef XHTONS
Note:
See TracChangeset
for help on using the changeset viewer.