1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-13 13:01:55 +03:00

Added openssl compatibility functions

git-svn-id: svn://svn.code.sf.net/p/axtls/code/trunk@64 9a5d90b5-6617-0410-8a86-bb477d3ed2e3
This commit is contained in:
cameronrich
2007-02-21 13:22:36 +00:00
parent 900b0eb96e
commit 6843c20d38
19 changed files with 278 additions and 57 deletions

View File

@ -30,7 +30,7 @@
#define BLOCKSIZE 4096
#define INITIAL_CONNECTION_SLOTS 10
#define CONFIG_HTTP_DEFAULT_SSL_OPTIONS 0
#define CONFIG_HTTP_DEFAULT_SSL_OPTIONS 0
#define STATE_WANT_TO_READ_HEAD 1
#define STATE_WANT_TO_SEND_HEAD 2
@ -52,6 +52,7 @@ struct connstruct
int reqtype;
int networkdesc;
int filedesc;
SSL *ssl;
#if defined(CONFIG_HTTP_DIRECTORIES)
#ifdef WIN32

View File

@ -48,6 +48,7 @@ static void reaper(int sigtype)
#endif
#endif
#ifdef CONFIG_HTTP_VERBOSE /* should really be in debug mode or something */
/* clean up memory for valgrind */
static void sigint_cleanup(int sig)
{
@ -96,6 +97,7 @@ static void die(int sigtype)
{
exit(0);
}
#endif
int main(int argc, char *argv[])
{
@ -112,15 +114,19 @@ int main(int argc, char *argv[])
WSADATA wsaData;
WSAStartup(wVersionRequested,&wsaData);
#else
signal(SIGQUIT, die);
signal(SIGPIPE, SIG_IGN);
#if defined(CONFIG_HTTP_HAS_CGI)
signal(SIGCHLD, reaper);
#endif
#ifdef CONFIG_HTTP_VERBOSE
signal(SIGQUIT, die);
#endif
#endif
signal(SIGINT, sigint_cleanup);
#ifdef CONFIG_HTTP_VERBOSE
signal(SIGTERM, die);
signal(SIGINT, sigint_cleanup);
#endif
mime_init();
tdate_init();
@ -576,7 +582,7 @@ static void addconnection(int sd, char *ip, int is_ssl)
tp->networkdesc = sd;
if (is_ssl)
ssl_server_new(servers->ssl_ctx, sd);
tp->ssl = ssl_server_new(servers->ssl_ctx, sd);
tp->is_ssl = is_ssl;
tp->filedesc = -1;
@ -632,7 +638,10 @@ void removeconnection(struct connstruct *cn)
if (cn->networkdesc != -1)
{
if (cn->is_ssl)
ssl_free(ssl_find(servers->ssl_ctx, cn->networkdesc));
{
ssl_free(cn->ssl);
cn->ssl = NULL;
}
SOCKET_CLOSE(cn->networkdesc);
}

View File

@ -375,6 +375,7 @@ void procsendhead(struct connstruct *cn)
{
char tbuf[MAXREQUESTLENGTH];
sprintf(tbuf, "%s%s", cn->actualfile, index_file);
if (stat(tbuf, &stbuf) != -1)
strcat(cn->actualfile, index_file);
else
@ -429,9 +430,9 @@ void procsendhead(struct connstruct *cn)
#if defined(WIN32) || defined(CONFIG_PLATFORM_CYGWIN)
flags |= O_BINARY;
#endif
cn->filedesc = open(cn->actualfile, flags);
cn->filedesc = ax_open(cn->actualfile, flags);
if (cn->filedesc == -1)
if (cn->filedesc < 0)
{
send_error(cn, 404);
return;
@ -472,7 +473,7 @@ void procreadfile(struct connstruct *cn)
{
int rv = read(cn->filedesc, cn->databuf, BLOCKSIZE);
if (rv == 0 || rv == -1)
if (rv <= 0)
{
close(cn->filedesc);
cn->filedesc = -1;
@ -516,7 +517,7 @@ static int special_write(struct connstruct *cn,
{
if (cn->is_ssl)
{
SSL *ssl = ssl_find(servers->ssl_ctx, cn->networkdesc);
SSL *ssl = cn->ssl;
return ssl ? ssl_write(ssl, (uint8_t *)buf, count) : -1;
}
else
@ -530,10 +531,10 @@ static int special_read(struct connstruct *cn, void *buf, size_t count)
if (cn->is_ssl)
{
uint8_t *read_buf;
SSL *ssl = ssl_find(servers->ssl_ctx, cn->networkdesc);
if ((res = ssl_read(ssl, &read_buf)) > SSL_OK)
if ((res = ssl_read(cn->ssl, &read_buf)) > SSL_OK)
{
memcpy(buf, read_buf, res > (int)count ? count : res);
}
}
else
res = SOCKET_READ(cn->networkdesc, buf, count);