[388] | 1 | /* io.h
|
---|
| 2 | *
|
---|
| 3 | * Copyright (C) 2006-2017 wolfSSL Inc.
|
---|
| 4 | *
|
---|
| 5 | * This file is part of wolfSSL.
|
---|
| 6 | *
|
---|
| 7 | * wolfSSL is free software; you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation; either version 2 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * wolfSSL is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with this program; if not, write to the Free Software
|
---|
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
---|
| 20 | */
|
---|
| 21 |
|
---|
| 22 | /*!
|
---|
| 23 | \file wolfssl/wolfio.h
|
---|
| 24 | */
|
---|
| 25 |
|
---|
| 26 | #ifndef WOLFSSL_IO_H
|
---|
| 27 | #define WOLFSSL_IO_H
|
---|
| 28 |
|
---|
| 29 | #ifdef __cplusplus
|
---|
| 30 | extern "C" {
|
---|
| 31 | #endif
|
---|
| 32 |
|
---|
| 33 | /* Micrium uses NetSock I/O callbacks in wolfio.c */
|
---|
| 34 | #if !defined(WOLFSSL_USER_IO)
|
---|
| 35 | /* OCSP and CRL_IO require HTTP client */
|
---|
| 36 | #if defined(HAVE_OCSP) || defined(HAVE_CRL_IO)
|
---|
| 37 | #ifndef HAVE_HTTP_CLIENT
|
---|
| 38 | #define HAVE_HTTP_CLIENT
|
---|
| 39 | #endif
|
---|
| 40 | #endif
|
---|
| 41 | #endif
|
---|
| 42 |
|
---|
| 43 | #if !defined(WOLFSSL_USER_IO)
|
---|
| 44 | /* Micrium uses NetSock I/O callbacks in wolfio.c */
|
---|
| 45 | #if !defined(USE_WOLFSSL_IO) && !defined(MICRIUM) && !defined(WOLFSSL_CONTIKI)
|
---|
| 46 | #define USE_WOLFSSL_IO
|
---|
| 47 | #endif
|
---|
| 48 | #endif
|
---|
| 49 |
|
---|
| 50 |
|
---|
| 51 | #if defined(USE_WOLFSSL_IO) || defined(HAVE_HTTP_CLIENT)
|
---|
| 52 |
|
---|
| 53 | #ifdef HAVE_LIBZ
|
---|
| 54 | #include "zlib.h"
|
---|
| 55 | #endif
|
---|
| 56 |
|
---|
| 57 | #ifndef USE_WINDOWS_API
|
---|
| 58 | #if defined(WOLFSSL_LWIP) && !defined(WOLFSSL_APACHE_MYNEWT)
|
---|
| 59 | /* lwIP needs to be configured to use sockets API in this mode */
|
---|
| 60 | /* LWIP_SOCKET 1 in lwip/opt.h or in build */
|
---|
| 61 | #include "lwip/sockets.h"
|
---|
| 62 | #ifndef LWIP_PROVIDE_ERRNO
|
---|
| 63 | #include <errno.h>
|
---|
| 64 | #define LWIP_PROVIDE_ERRNO 1
|
---|
| 65 | #endif
|
---|
| 66 | #elif defined(FREESCALE_MQX)
|
---|
| 67 | #include <posix.h>
|
---|
| 68 | #include <rtcs.h>
|
---|
| 69 | #elif defined(FREESCALE_KSDK_MQX)
|
---|
| 70 | #include <rtcs.h>
|
---|
| 71 | #elif (defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET))
|
---|
| 72 | #include "cmsis_os.h"
|
---|
| 73 | #include "rl_net.h"
|
---|
| 74 | #include "errno.h"
|
---|
| 75 | #elif defined(WOLFSSL_CMSIS_RTOS)
|
---|
| 76 | #include "cmsis_os.h"
|
---|
| 77 | #elif defined(WOLFSSL_TIRTOS)
|
---|
| 78 | #include <sys/socket.h>
|
---|
| 79 | #elif defined(FREERTOS_TCP)
|
---|
| 80 | #include "FreeRTOS_Sockets.h"
|
---|
| 81 | #elif defined(WOLFSSL_IAR_ARM)
|
---|
| 82 | /* nothing */
|
---|
| 83 | #elif defined(WOLFSSL_VXWORKS)
|
---|
| 84 | #include <sockLib.h>
|
---|
| 85 | #include <errno.h>
|
---|
| 86 | #elif defined(WOLFSSL_NUCLEUS_1_2)
|
---|
| 87 | #include <externs.h>
|
---|
| 88 | #include <errno.h>
|
---|
| 89 | #elif defined(WOLFSSL_ATMEL)
|
---|
| 90 | #include "socket/include/socket.h"
|
---|
| 91 | #elif defined(INTIME_RTOS)
|
---|
| 92 | #undef MIN
|
---|
| 93 | #undef MAX
|
---|
| 94 | #include <rt.h>
|
---|
| 95 | #include <sys/types.h>
|
---|
| 96 | #include <sys/socket.h>
|
---|
| 97 | #include <netdb.h>
|
---|
| 98 | #include <netinet/in.h>
|
---|
| 99 | #include <io.h>
|
---|
| 100 | /* <sys/socket.h> defines these, to avoid conflict, do undef */
|
---|
| 101 | #undef SOCKADDR
|
---|
| 102 | #undef SOCKADDR_IN
|
---|
| 103 | #elif defined(WOLFSSL_PRCONNECT_PRO)
|
---|
| 104 | #include <prconnect_pro/prconnect_pro.h>
|
---|
| 105 | #include <sys/types.h>
|
---|
| 106 | #include <errno.h>
|
---|
| 107 | #include <unistd.h>
|
---|
| 108 | #include <fcntl.h>
|
---|
| 109 | #include <netdb.h>
|
---|
| 110 | #include <sys/ioctl.h>
|
---|
| 111 | #elif defined(WOLFSSL_SGX)
|
---|
| 112 | #include <errno.h>
|
---|
| 113 | #elif defined(WOLFSSL_APACHE_MYNEWT) && !defined(WOLFSSL_LWIP)
|
---|
| 114 | #include <mn_socket/mn_socket.h>
|
---|
| 115 | #elif !defined(WOLFSSL_NO_SOCK)
|
---|
| 116 | #include <sys/types.h>
|
---|
| 117 | #include <errno.h>
|
---|
| 118 | #ifndef EBSNET
|
---|
| 119 | #include <unistd.h>
|
---|
| 120 | #endif
|
---|
| 121 | #include <fcntl.h>
|
---|
| 122 |
|
---|
| 123 | #if defined(HAVE_RTP_SYS)
|
---|
| 124 | #include <socket.h>
|
---|
| 125 | #elif defined(EBSNET)
|
---|
| 126 | #include "rtipapi.h" /* errno */
|
---|
| 127 | #include "socket.h"
|
---|
| 128 | #elif !defined(DEVKITPRO) && !defined(WOLFSSL_PICOTCP) && !defined(WOLFSSL_CONTIKI)
|
---|
| 129 | #include <sys/socket.h>
|
---|
| 130 | #include <arpa/inet.h>
|
---|
| 131 | #include <netinet/in.h>
|
---|
| 132 | #include <netdb.h>
|
---|
| 133 | #ifdef __PPU
|
---|
| 134 | #include <netex/errno.h>
|
---|
| 135 | #else
|
---|
| 136 | #include <sys/ioctl.h>
|
---|
| 137 | #endif
|
---|
| 138 | #endif
|
---|
| 139 | #endif
|
---|
| 140 | #endif /* USE_WINDOWS_API */
|
---|
| 141 |
|
---|
| 142 | #ifdef __sun
|
---|
| 143 | #include <sys/filio.h>
|
---|
| 144 | #endif
|
---|
| 145 |
|
---|
| 146 | #ifdef USE_WINDOWS_API
|
---|
| 147 | /* no epipe yet */
|
---|
| 148 | #ifndef WSAEPIPE
|
---|
| 149 | #define WSAEPIPE -12345
|
---|
| 150 | #endif
|
---|
| 151 | #define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK
|
---|
| 152 | #define SOCKET_EAGAIN WSAETIMEDOUT
|
---|
| 153 | #define SOCKET_ECONNRESET WSAECONNRESET
|
---|
| 154 | #define SOCKET_EINTR WSAEINTR
|
---|
| 155 | #define SOCKET_EPIPE WSAEPIPE
|
---|
| 156 | #define SOCKET_ECONNREFUSED WSAENOTCONN
|
---|
| 157 | #define SOCKET_ECONNABORTED WSAECONNABORTED
|
---|
| 158 | #elif defined(__PPU)
|
---|
| 159 | #define SOCKET_EWOULDBLOCK SYS_NET_EWOULDBLOCK
|
---|
| 160 | #define SOCKET_EAGAIN SYS_NET_EAGAIN
|
---|
| 161 | #define SOCKET_ECONNRESET SYS_NET_ECONNRESET
|
---|
| 162 | #define SOCKET_EINTR SYS_NET_EINTR
|
---|
| 163 | #define SOCKET_EPIPE SYS_NET_EPIPE
|
---|
| 164 | #define SOCKET_ECONNREFUSED SYS_NET_ECONNREFUSED
|
---|
| 165 | #define SOCKET_ECONNABORTED SYS_NET_ECONNABORTED
|
---|
| 166 | #elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
---|
| 167 | #if MQX_USE_IO_OLD
|
---|
| 168 | /* RTCS old I/O doesn't have an EWOULDBLOCK */
|
---|
| 169 | #define SOCKET_EWOULDBLOCK EAGAIN
|
---|
| 170 | #define SOCKET_EAGAIN EAGAIN
|
---|
| 171 | #define SOCKET_ECONNRESET RTCSERR_TCP_CONN_RESET
|
---|
| 172 | #define SOCKET_EINTR EINTR
|
---|
| 173 | #define SOCKET_EPIPE EPIPE
|
---|
| 174 | #define SOCKET_ECONNREFUSED RTCSERR_TCP_CONN_REFUSED
|
---|
| 175 | #define SOCKET_ECONNABORTED RTCSERR_TCP_CONN_ABORTED
|
---|
| 176 | #else
|
---|
| 177 | #define SOCKET_EWOULDBLOCK NIO_EWOULDBLOCK
|
---|
| 178 | #define SOCKET_EAGAIN NIO_EAGAIN
|
---|
| 179 | #define SOCKET_ECONNRESET NIO_ECONNRESET
|
---|
| 180 | #define SOCKET_EINTR NIO_EINTR
|
---|
| 181 | #define SOCKET_EPIPE NIO_EPIPE
|
---|
| 182 | #define SOCKET_ECONNREFUSED NIO_ECONNREFUSED
|
---|
| 183 | #define SOCKET_ECONNABORTED NIO_ECONNABORTED
|
---|
| 184 | #endif
|
---|
| 185 | #elif defined(WOLFSSL_MDK_ARM)|| defined(WOLFSSL_KEIL_TCP_NET)
|
---|
| 186 | #define SOCKET_EWOULDBLOCK BSD_ERROR_WOULDBLOCK
|
---|
| 187 | #define SOCKET_EAGAIN BSD_ERROR_LOCKED
|
---|
| 188 | #define SOCKET_ECONNRESET BSD_ERROR_CLOSED
|
---|
| 189 | #define SOCKET_EINTR BSD_ERROR
|
---|
| 190 | #define SOCKET_EPIPE BSD_ERROR
|
---|
| 191 | #define SOCKET_ECONNREFUSED BSD_ERROR
|
---|
| 192 | #define SOCKET_ECONNABORTED BSD_ERROR
|
---|
| 193 | #elif defined(WOLFSSL_PICOTCP)
|
---|
| 194 | #define SOCKET_EWOULDBLOCK PICO_ERR_EAGAIN
|
---|
| 195 | #define SOCKET_EAGAIN PICO_ERR_EAGAIN
|
---|
| 196 | #define SOCKET_ECONNRESET PICO_ERR_ECONNRESET
|
---|
| 197 | #define SOCKET_EINTR PICO_ERR_EINTR
|
---|
| 198 | #define SOCKET_EPIPE PICO_ERR_EIO
|
---|
| 199 | #define SOCKET_ECONNREFUSED PICO_ERR_ECONNREFUSED
|
---|
| 200 | #define SOCKET_ECONNABORTED PICO_ERR_ESHUTDOWN
|
---|
| 201 | #elif defined(FREERTOS_TCP)
|
---|
| 202 | #define SOCKET_EWOULDBLOCK FREERTOS_EWOULDBLOCK
|
---|
| 203 | #define SOCKET_EAGAIN FREERTOS_EWOULDBLOCK
|
---|
| 204 | #define SOCKET_ECONNRESET FREERTOS_SOCKET_ERROR
|
---|
| 205 | #define SOCKET_EINTR FREERTOS_SOCKET_ERROR
|
---|
| 206 | #define SOCKET_EPIPE FREERTOS_SOCKET_ERROR
|
---|
| 207 | #define SOCKET_ECONNREFUSED FREERTOS_SOCKET_ERROR
|
---|
| 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
|
---|
| 217 | #else
|
---|
| 218 | #define SOCKET_EWOULDBLOCK EWOULDBLOCK
|
---|
| 219 | #define SOCKET_EAGAIN EAGAIN
|
---|
| 220 | #define SOCKET_ECONNRESET ECONNRESET
|
---|
| 221 | #define SOCKET_EINTR EINTR
|
---|
| 222 | #define SOCKET_EPIPE EPIPE
|
---|
| 223 | #define SOCKET_ECONNREFUSED ECONNREFUSED
|
---|
| 224 | #define SOCKET_ECONNABORTED ECONNABORTED
|
---|
| 225 | #endif /* USE_WINDOWS_API */
|
---|
| 226 |
|
---|
| 227 |
|
---|
| 228 |
|
---|
| 229 |
|
---|
| 230 | #ifdef DEVKITPRO
|
---|
| 231 | /* from network.h */
|
---|
| 232 | int net_send(int, const void*, int, unsigned int);
|
---|
| 233 | int net_recv(int, void*, int, unsigned int);
|
---|
| 234 | #define SEND_FUNCTION net_send
|
---|
| 235 | #define RECV_FUNCTION net_recv
|
---|
| 236 | #elif defined(WOLFSSL_LWIP) && !defined(WOLFSSL_APACHE_MYNEWT)
|
---|
| 237 | #define SEND_FUNCTION lwip_send
|
---|
| 238 | #define RECV_FUNCTION lwip_recv
|
---|
| 239 | #elif defined(WOLFSSL_PICOTCP)
|
---|
| 240 | #define SEND_FUNCTION pico_send
|
---|
| 241 | #define RECV_FUNCTION pico_recv
|
---|
| 242 | #elif defined(FREERTOS_TCP)
|
---|
| 243 | #define RECV_FUNCTION(a,b,c,d) FreeRTOS_recv((Socket_t)(a),(void*)(b), (size_t)(c), (BaseType_t)(d))
|
---|
| 244 | #define SEND_FUNCTION(a,b,c,d) FreeRTOS_send((Socket_t)(a),(void*)(b), (size_t)(c), (BaseType_t)(d))
|
---|
| 245 | #elif defined(WOLFSSL_VXWORKS)
|
---|
| 246 | #define SEND_FUNCTION send
|
---|
| 247 | #define RECV_FUNCTION recv
|
---|
| 248 | #elif defined(WOLFSSL_NUCLEUS_1_2)
|
---|
| 249 | #define SEND_FUNCTION NU_Send
|
---|
| 250 | #define RECV_FUNCTION NU_Recv
|
---|
| 251 | #else
|
---|
| 252 | #define SEND_FUNCTION send
|
---|
| 253 | #define RECV_FUNCTION recv
|
---|
| 254 | #if !defined(HAVE_SOCKADDR) && !defined(WOLFSSL_NO_SOCK)
|
---|
| 255 | #define HAVE_SOCKADDR
|
---|
| 256 | #endif
|
---|
| 257 | #endif
|
---|
| 258 |
|
---|
| 259 | #ifdef USE_WINDOWS_API
|
---|
| 260 | typedef unsigned int SOCKET_T;
|
---|
| 261 | #else
|
---|
| 262 | typedef int SOCKET_T;
|
---|
| 263 | #endif
|
---|
| 264 |
|
---|
| 265 | #ifndef WOLFSSL_NO_SOCK
|
---|
| 266 | #ifndef XSOCKLENT
|
---|
| 267 | #ifdef USE_WINDOWS_API
|
---|
| 268 | #define XSOCKLENT int
|
---|
| 269 | #else
|
---|
| 270 | #define XSOCKLENT socklen_t
|
---|
| 271 | #endif
|
---|
| 272 | #endif
|
---|
| 273 |
|
---|
| 274 | /* Socket Addr Support */
|
---|
| 275 | #ifdef HAVE_SOCKADDR
|
---|
| 276 | typedef struct sockaddr SOCKADDR;
|
---|
| 277 | typedef struct sockaddr_storage SOCKADDR_S;
|
---|
| 278 | typedef struct sockaddr_in SOCKADDR_IN;
|
---|
| 279 | #ifdef WOLFSSL_IPV6
|
---|
| 280 | typedef struct sockaddr_in6 SOCKADDR_IN6;
|
---|
| 281 | #endif
|
---|
| 282 | typedef struct hostent HOSTENT;
|
---|
| 283 | #endif /* HAVE_SOCKADDR */
|
---|
| 284 |
|
---|
| 285 | /* use gethostbyname for c99 */
|
---|
| 286 | #ifdef WOLF_C99
|
---|
| 287 | #undef HAVE_GETADDRINFO
|
---|
| 288 | #endif
|
---|
| 289 |
|
---|
| 290 | #ifdef HAVE_GETADDRINFO
|
---|
| 291 | typedef struct addrinfo ADDRINFO;
|
---|
| 292 | #endif
|
---|
| 293 | #endif /* WOLFSSL_NO_SOCK */
|
---|
| 294 |
|
---|
| 295 |
|
---|
| 296 | /* IO API's */
|
---|
| 297 | #ifdef HAVE_IO_TIMEOUT
|
---|
| 298 | WOLFSSL_API int wolfIO_SetBlockingMode(SOCKET_T sockfd, int non_blocking);
|
---|
| 299 | WOLFSSL_API void wolfIO_SetTimeout(int to_sec);
|
---|
| 300 | WOLFSSL_API int wolfIO_Select(SOCKET_T sockfd, int to_sec);
|
---|
| 301 | #endif
|
---|
| 302 | WOLFSSL_API int wolfIO_TcpConnect(SOCKET_T* sockfd, const char* ip,
|
---|
| 303 | unsigned short port, int to_sec);
|
---|
| 304 | WOLFSSL_API int wolfIO_Send(SOCKET_T sd, char *buf, int sz, int wrFlags);
|
---|
| 305 | WOLFSSL_API int wolfIO_Recv(SOCKET_T sd, char *buf, int sz, int rdFlags);
|
---|
| 306 |
|
---|
| 307 | #endif /* USE_WOLFSSL_IO || HAVE_HTTP_CLIENT */
|
---|
| 308 |
|
---|
| 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);
|
---|
| 334 | #if defined(USE_WOLFSSL_IO)
|
---|
| 335 | /* default IO callbacks */
|
---|
| 336 | WOLFSSL_API int EmbedReceive(WOLFSSL* ssl, char* buf, int sz, void* ctx);
|
---|
| 337 | WOLFSSL_API int EmbedSend(WOLFSSL* ssl, char* buf, int sz, void* ctx);
|
---|
| 338 |
|
---|
| 339 | #ifdef WOLFSSL_DTLS
|
---|
| 340 | WOLFSSL_API int EmbedReceiveFrom(WOLFSSL* ssl, char* buf, int sz, void*);
|
---|
| 341 | WOLFSSL_API int EmbedSendTo(WOLFSSL* ssl, char* buf, int sz, void* ctx);
|
---|
| 342 | WOLFSSL_API int EmbedGenerateCookie(WOLFSSL* ssl, unsigned char* buf,
|
---|
| 343 | int sz, void*);
|
---|
| 344 | #ifdef WOLFSSL_MULTICAST
|
---|
| 345 | WOLFSSL_API int EmbedReceiveFromMcast(WOLFSSL* ssl,
|
---|
| 346 | char* buf, int sz, void*);
|
---|
| 347 | #endif /* WOLFSSL_MULTICAST */
|
---|
| 348 | #ifdef WOLFSSL_SESSION_EXPORT
|
---|
| 349 | WOLFSSL_API int EmbedGetPeer(WOLFSSL* ssl, char* ip, int* ipSz,
|
---|
| 350 | unsigned short* port, int* fam);
|
---|
| 351 | WOLFSSL_API int EmbedSetPeer(WOLFSSL* ssl, char* ip, int ipSz,
|
---|
| 352 | unsigned short port, int fam);
|
---|
| 353 | #endif /* WOLFSSL_SESSION_EXPORT */
|
---|
| 354 | #endif /* WOLFSSL_DTLS */
|
---|
| 355 | #endif /* USE_WOLFSSL_IO */
|
---|
| 356 |
|
---|
| 357 | #ifdef HAVE_OCSP
|
---|
| 358 | WOLFSSL_API int wolfIO_HttpBuildRequestOcsp(const char* domainName,
|
---|
| 359 | const char* path, int ocspReqSz, unsigned char* buf, int bufSize);
|
---|
| 360 | WOLFSSL_API int wolfIO_HttpProcessResponseOcsp(int sfd,
|
---|
| 361 | unsigned char** respBuf, unsigned char* httpBuf, int httpBufSz,
|
---|
| 362 | void* heap);
|
---|
| 363 |
|
---|
| 364 | WOLFSSL_API int EmbedOcspLookup(void*, const char*, int, unsigned char*,
|
---|
| 365 | int, unsigned char**);
|
---|
| 366 | WOLFSSL_API void EmbedOcspRespFree(void*, unsigned char*);
|
---|
| 367 | #endif
|
---|
| 368 |
|
---|
| 369 | #ifdef HAVE_CRL_IO
|
---|
| 370 | WOLFSSL_API int wolfIO_HttpBuildRequestCrl(const char* url, int urlSz,
|
---|
| 371 | const char* domainName, unsigned char* buf, int bufSize);
|
---|
| 372 | WOLFSSL_API int wolfIO_HttpProcessResponseCrl(WOLFSSL_CRL* crl, int sfd,
|
---|
| 373 | unsigned char* httpBuf, int httpBufSz);
|
---|
| 374 |
|
---|
| 375 | WOLFSSL_API int EmbedCrlLookup(WOLFSSL_CRL* crl, const char* url,
|
---|
| 376 | int urlSz);
|
---|
| 377 | #endif
|
---|
| 378 |
|
---|
| 379 |
|
---|
| 380 | #if defined(HAVE_HTTP_CLIENT)
|
---|
| 381 | WOLFSSL_API int wolfIO_DecodeUrl(const char* url, int urlSz, char* outName,
|
---|
| 382 | char* outPath, unsigned short* outPort);
|
---|
| 383 |
|
---|
| 384 | WOLFSSL_API int wolfIO_HttpBuildRequest(const char* reqType,
|
---|
| 385 | const char* domainName, const char* path, int pathLen, int reqSz,
|
---|
| 386 | const char* contentType, unsigned char* buf, int bufSize);
|
---|
| 387 | WOLFSSL_API int wolfIO_HttpProcessResponse(int sfd, const char** appStrList,
|
---|
| 388 | unsigned char** respBuf, unsigned char* httpBuf, int httpBufSz,
|
---|
| 389 | int dynType, void* heap);
|
---|
| 390 | #endif /* HAVE_HTTP_CLIENT */
|
---|
| 391 |
|
---|
| 392 |
|
---|
| 393 | /* I/O callbacks */
|
---|
| 394 | typedef int (*CallbackIORecv)(WOLFSSL *ssl, char *buf, int sz, void *ctx);
|
---|
| 395 | typedef int (*CallbackIOSend)(WOLFSSL *ssl, char *buf, int sz, void *ctx);
|
---|
| 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
|
---|
| 401 |
|
---|
| 402 | WOLFSSL_API void wolfSSL_SetIOReadCtx( WOLFSSL* ssl, void *ctx);
|
---|
| 403 | WOLFSSL_API void wolfSSL_SetIOWriteCtx(WOLFSSL* ssl, void *ctx);
|
---|
| 404 |
|
---|
| 405 | WOLFSSL_API void* wolfSSL_GetIOReadCtx( WOLFSSL* ssl);
|
---|
| 406 | WOLFSSL_API void* wolfSSL_GetIOWriteCtx(WOLFSSL* ssl);
|
---|
| 407 |
|
---|
| 408 | WOLFSSL_API void wolfSSL_SetIOReadFlags( WOLFSSL* ssl, int flags);
|
---|
| 409 | WOLFSSL_API void wolfSSL_SetIOWriteFlags(WOLFSSL* ssl, int flags);
|
---|
| 410 |
|
---|
| 411 |
|
---|
| 412 | #ifdef HAVE_NETX
|
---|
| 413 | WOLFSSL_LOCAL int NetX_Receive(WOLFSSL *ssl, char *buf, int sz, void *ctx);
|
---|
| 414 | WOLFSSL_LOCAL int NetX_Send(WOLFSSL *ssl, char *buf, int sz, void *ctx);
|
---|
| 415 |
|
---|
| 416 | WOLFSSL_API void wolfSSL_SetIO_NetX(WOLFSSL* ssl, NX_TCP_SOCKET* nxsocket,
|
---|
| 417 | ULONG waitoption);
|
---|
| 418 | #endif /* HAVE_NETX */
|
---|
| 419 |
|
---|
| 420 | #ifdef MICRIUM
|
---|
| 421 | WOLFSSL_LOCAL int MicriumSend(WOLFSSL* ssl, char* buf, int sz, void* ctx);
|
---|
| 422 | WOLFSSL_LOCAL int MicriumReceive(WOLFSSL* ssl, char* buf, int sz,
|
---|
| 423 | void* ctx);
|
---|
| 424 | WOLFSSL_LOCAL int MicriumReceiveFrom(WOLFSSL* ssl, char* buf, int sz,
|
---|
| 425 | void* ctx);
|
---|
| 426 | WOLFSSL_LOCAL int MicriumSendTo(WOLFSSL* ssl, char* buf, int sz, void* ctx);
|
---|
| 427 | #endif /* MICRIUM */
|
---|
| 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 |
|
---|
| 469 | #ifdef WOLFSSL_DTLS
|
---|
| 470 | typedef int (*CallbackGenCookie)(WOLFSSL* ssl, unsigned char* buf, int sz,
|
---|
| 471 | void* ctx);
|
---|
| 472 | WOLFSSL_API void wolfSSL_CTX_SetGenCookie(WOLFSSL_CTX*, CallbackGenCookie);
|
---|
| 473 | WOLFSSL_API void wolfSSL_SetCookieCtx(WOLFSSL* ssl, void *ctx);
|
---|
| 474 | WOLFSSL_API void* wolfSSL_GetCookieCtx(WOLFSSL* ssl);
|
---|
| 475 |
|
---|
| 476 | #ifdef WOLFSSL_SESSION_EXPORT
|
---|
| 477 | typedef int (*CallbackGetPeer)(WOLFSSL* ssl, char* ip, int* ipSz,
|
---|
| 478 | unsigned short* port, int* fam);
|
---|
| 479 | typedef int (*CallbackSetPeer)(WOLFSSL* ssl, char* ip, int ipSz,
|
---|
| 480 | unsigned short port, int fam);
|
---|
| 481 |
|
---|
| 482 | WOLFSSL_API void wolfSSL_CTX_SetIOGetPeer(WOLFSSL_CTX*, CallbackGetPeer);
|
---|
| 483 | WOLFSSL_API void wolfSSL_CTX_SetIOSetPeer(WOLFSSL_CTX*, CallbackSetPeer);
|
---|
| 484 | #endif /* WOLFSSL_SESSION_EXPORT */
|
---|
| 485 | #endif
|
---|
| 486 |
|
---|
| 487 |
|
---|
| 488 |
|
---|
| 489 | #ifndef XINET_NTOP
|
---|
| 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
|
---|
| 495 | #endif
|
---|
| 496 | #ifndef XINET_PTON
|
---|
| 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
|
---|
| 502 | #endif
|
---|
| 503 | #ifndef XHTONS
|
---|
| 504 | #define XHTONS(a) htons((a))
|
---|
| 505 | #endif
|
---|
| 506 | #ifndef XNTOHS
|
---|
| 507 | #define XNTOHS(a) ntohs((a))
|
---|
| 508 | #endif
|
---|
| 509 |
|
---|
| 510 | #ifndef WOLFSSL_IP4
|
---|
| 511 | #define WOLFSSL_IP4 AF_INET
|
---|
| 512 | #endif
|
---|
| 513 | #ifndef WOLFSSL_IP6
|
---|
| 514 | #define WOLFSSL_IP6 AF_INET6
|
---|
| 515 | #endif
|
---|
| 516 |
|
---|
| 517 |
|
---|
| 518 | #ifdef __cplusplus
|
---|
| 519 | } /* extern "C" */
|
---|
| 520 | #endif
|
---|
| 521 |
|
---|
| 522 | #endif /* WOLFSSL_IO_H */
|
---|