mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-12 01:53:07 +03:00
Added Visual Studio 2010 support and fixed some VS compilation issues.
Removed code to force blocking mode. git-svn-id: svn://svn.code.sf.net/p/axtls/code/trunk@196 9a5d90b5-6617-0410-8a86-bb477d3ed2e3
This commit is contained in:
@ -82,8 +82,6 @@ extern "C" {
|
||||
#define SOCKET_READ(A,B,C) recv(A,B,C,0)
|
||||
#define SOCKET_WRITE(A,B,C) send(A,B,C,0)
|
||||
#define SOCKET_CLOSE(A) closesocket(A)
|
||||
#define SOCKET_BLOCK(A) u_long argp = 0; \
|
||||
ioctlsocket(A, FIONBIO, &argp)
|
||||
#define srandom(A) srand(A)
|
||||
#define random() rand()
|
||||
#define getpid() _getpid()
|
||||
@ -143,6 +141,7 @@ EXP_FUNC int STDCALL getdomainname(char *buf, int buf_size);
|
||||
#include <netdb.h>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
@ -153,8 +152,6 @@ EXP_FUNC int STDCALL getdomainname(char *buf, int buf_size);
|
||||
#define SOCKET_READ(A,B,C) read(A,B,C)
|
||||
#define SOCKET_WRITE(A,B,C) write(A,B,C)
|
||||
#define SOCKET_CLOSE(A) if (A >= 0) close(A)
|
||||
#define SOCKET_BLOCK(A) int fd = fcntl(A, F_GETFL, NULL); \
|
||||
fcntl(A, F_SETFL, fd & ~O_NONBLOCK)
|
||||
#define TTY_FLUSH()
|
||||
|
||||
#endif /* Not Win32 */
|
||||
|
@ -197,7 +197,8 @@ extern "C" {
|
||||
* are passed during a handshake.
|
||||
* - SSL_DISPLAY_RSA (full mode build only): Display the RSA key details that
|
||||
* are passed during a handshake.
|
||||
*
|
||||
* - SSL_CLIENT_NON_BLOCKING (client only): Use non-blocking version of
|
||||
* ssl_client_new.
|
||||
* @param num_sessions [in] The number of sessions to be used for session
|
||||
* caching. If this value is 0, then there is no session caching. This option
|
||||
* is not used in skeleton mode.
|
||||
@ -231,8 +232,9 @@ EXP_FUNC SSL * STDCALL ssl_server_new(SSL_CTX *ssl_ctx, int client_fd);
|
||||
* It is up to the application to establish the initial logical connection
|
||||
* (whether it is a socket, serial connection etc).
|
||||
*
|
||||
* This is a blocking call - it will finish when the handshake is complete (or
|
||||
* has failed).
|
||||
* This is a normall a blocking call - it will finish when the handshake is
|
||||
* complete (or has failed). To use in non-blocking mode, set
|
||||
* SSL_CLIENT_NON_BLOCKING in ssl_ctx_new.
|
||||
* @param ssl_ctx [in] The client context.
|
||||
* @param client_fd [in] The client's file descriptor.
|
||||
* @param session_id [in] A 32 byte session id for session resumption. This
|
||||
|
@ -287,6 +287,7 @@ EXP_FUNC int STDCALL ssl_read(SSL *ssl, uint8_t **in_data)
|
||||
int ret = basic_read(ssl, in_data);
|
||||
|
||||
/* check for return code so we can send an alert */
|
||||
|
||||
if (ret < SSL_OK && ret != SSL_CLOSE_NOTIFY)
|
||||
{
|
||||
if (ret != SSL_ERROR_CONN_LOST)
|
||||
@ -1159,6 +1160,14 @@ int basic_read(SSL *ssl, uint8_t **in_data)
|
||||
read_len = SOCKET_READ(ssl->client_fd, &buf[ssl->bm_read_index],
|
||||
ssl->need_bytes-ssl->got_bytes);
|
||||
|
||||
if (ret < 0)
|
||||
#ifdef WIN32
|
||||
if (GetLastError() == WSAEWOULDBLOCK)
|
||||
#else
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK)
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
/* connection has gone, so die */
|
||||
if (read_len <= 0)
|
||||
{
|
||||
|
@ -50,10 +50,7 @@ static int send_cert_verify(SSL *ssl);
|
||||
EXP_FUNC SSL * STDCALL ssl_client_new(SSL_CTX *ssl_ctx, int client_fd, const
|
||||
uint8_t *session_id, uint8_t sess_id_size)
|
||||
{
|
||||
SSL *ssl;
|
||||
|
||||
SOCKET_BLOCK(client_fd); /* ensure blocking mode */
|
||||
ssl = ssl_new(ssl_ctx, client_fd);
|
||||
SSL *ssl = ssl_new(ssl_ctx, client_fd);
|
||||
|
||||
if (session_id && ssl_ctx->num_sessions)
|
||||
{
|
||||
|
Reference in New Issue
Block a user