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