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