wolfSSL SSL/TLS library, support up to TLS1.3

Dependents:   CyaSSL-Twitter-OAuth4Tw Example-client-tls-cert TwitterReader TweetTest ... more

Committer:
wolfSSL
Date:
Tue Aug 22 10:48:22 2017 +0000
Revision:
13:f67a6c6013ca
wolfSSL3.12.0 with TLS1.3

Who changed what in which revision?

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