mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-27 21:16:50 +03:00
added mime option to axhttpd. Improved cygwin library build
git-svn-id: svn://svn.code.sf.net/p/axtls/code/trunk@52 9a5d90b5-6617-0410-8a86-bb477d3ed2e3
This commit is contained in:
parent
8213b750a1
commit
dabdec8fcc
7
Makefile
7
Makefile
@ -69,9 +69,10 @@ win32_demo:
|
|||||||
install: $(PREFIX) all
|
install: $(PREFIX) all
|
||||||
cp --no-dereference $(STAGE)/libax* $(PREFIX)/lib
|
cp --no-dereference $(STAGE)/libax* $(PREFIX)/lib
|
||||||
chmod 755 $(PREFIX)/lib/libax*
|
chmod 755 $(PREFIX)/lib/libax*
|
||||||
-@install -m 755 $(STAGE)/ax* $(PREFIX)/bin > /dev/null 2>&1
|
-install -m 755 $(STAGE)/ax* $(PREFIX)/bin > /dev/null 2>&1
|
||||||
-@install -m 755 $(STAGE)/axtlsp.pm `perl -e 'use Config; print $$Config{installarchlib};'` > /dev/null 2>&1
|
ifdef CONFIG_PERL_BINDINGS
|
||||||
-@install -m 755 $(STAGE)/axhttpd* $(PREFIX)/bin > /dev/null 2>&1
|
-install -m 755 $(STAGE)/axtlsp.pm `perl -e 'use Config; print $$Config{installarchlib};'` > /dev/null 2>&1
|
||||||
|
endif
|
||||||
|
|
||||||
installclean:
|
installclean:
|
||||||
-@rm $(PREFIX)/lib/libax* > /dev/null 2>&1
|
-@rm $(PREFIX)/lib/libax* > /dev/null 2>&1
|
||||||
|
@ -55,6 +55,7 @@ CONFIG_HTTP_CGI_EXTENSION=""
|
|||||||
# CONFIG_HTTP_DIRECTORIES is not set
|
# CONFIG_HTTP_DIRECTORIES is not set
|
||||||
# CONFIG_HTTP_PERM_CHECK is not set
|
# CONFIG_HTTP_PERM_CHECK is not set
|
||||||
# CONFIG_HTTP_HAS_IPV6 is not set
|
# CONFIG_HTTP_HAS_IPV6 is not set
|
||||||
|
CONFIG_HTTP_ALL_MIME_TYPES=y
|
||||||
# CONFIG_HTTP_VERBOSE is not set
|
# CONFIG_HTTP_VERBOSE is not set
|
||||||
# CONFIG_HTTP_IS_DAEMON is not set
|
# CONFIG_HTTP_IS_DAEMON is not set
|
||||||
|
|
||||||
|
@ -62,6 +62,7 @@ CONFIG_HTTP_CGI_EXTENSION=""
|
|||||||
CONFIG_HTTP_DIRECTORIES=y
|
CONFIG_HTTP_DIRECTORIES=y
|
||||||
# CONFIG_HTTP_PERM_CHECK is not set
|
# CONFIG_HTTP_PERM_CHECK is not set
|
||||||
# CONFIG_HTTP_HAS_IPV6 is not set
|
# CONFIG_HTTP_HAS_IPV6 is not set
|
||||||
|
CONFIG_HTTP_ALL_MIME_TYPES=y
|
||||||
CONFIG_HTTP_VERBOSE=y
|
CONFIG_HTTP_VERBOSE=y
|
||||||
# CONFIG_HTTP_IS_DAEMON is not set
|
# CONFIG_HTTP_IS_DAEMON is not set
|
||||||
|
|
||||||
|
@ -88,6 +88,17 @@ config CONFIG_HTTP_HAS_IPV6
|
|||||||
|
|
||||||
Does not work under Win32
|
Does not work under Win32
|
||||||
|
|
||||||
|
config CONFIG_HTTP_ALL_MIME_TYPES
|
||||||
|
bool "Use all mime types"
|
||||||
|
default y if CONFIG_SSL_FULL_MODE
|
||||||
|
default n if !CONFIG_SSL_FULL_MODE
|
||||||
|
help
|
||||||
|
Use the full list of supported mime types.
|
||||||
|
|
||||||
|
Use this option if a "generic" webserver is used. However if it is
|
||||||
|
using only web pages (html, jpg, gif, png, css) then select this
|
||||||
|
option.
|
||||||
|
|
||||||
config CONFIG_HTTP_VERBOSE
|
config CONFIG_HTTP_VERBOSE
|
||||||
bool "Verbose Mode"
|
bool "Verbose Mode"
|
||||||
default y if CONFIG_SSL_FULL_MODE
|
default y if CONFIG_SSL_FULL_MODE
|
||||||
|
@ -47,7 +47,7 @@ LIBS=../$(STAGE)/axtls.lib ..\\config\\axtls.res
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifndef CONFIG_AWHTTPD
|
ifndef CONFIG_AXHTTPD
|
||||||
web_server:
|
web_server:
|
||||||
else
|
else
|
||||||
|
|
||||||
@ -56,18 +56,13 @@ web_server : $(TARGET)
|
|||||||
OBJ= \
|
OBJ= \
|
||||||
conn.o \
|
conn.o \
|
||||||
main.o \
|
main.o \
|
||||||
net.o \
|
|
||||||
proc.o \
|
proc.o \
|
||||||
socket.o \
|
|
||||||
misc.o \
|
misc.o \
|
||||||
mime_types.o
|
mime_types.o
|
||||||
|
|
||||||
ifndef CONFIG_PLATFORM_WIN32
|
ifndef CONFIG_PLATFORM_WIN32
|
||||||
|
|
||||||
$(TARGET): $(OBJ)
|
$(TARGET): $(OBJ) ../$(STAGE)/libaxtls.a
|
||||||
ifdef CONFIG_HTTP_NO_SSL
|
|
||||||
$(LD) $(LDFLAGS) -o $@ $(OBJ)
|
|
||||||
endif
|
|
||||||
$(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
|
$(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
|
||||||
ifndef CONFIG_DEBUG
|
ifndef CONFIG_DEBUG
|
||||||
ifndef CONFIG_PLATFORM_SOLARIS
|
ifndef CONFIG_PLATFORM_SOLARIS
|
||||||
@ -77,13 +72,10 @@ endif
|
|||||||
else # Win32
|
else # Win32
|
||||||
|
|
||||||
$(TARGET): $(OBJ)
|
$(TARGET): $(OBJ)
|
||||||
ifdef CONFIG_HTTP_NO_SSL
|
|
||||||
$(LD) $(LDFLAGS) /out:$@ $(OBJ)
|
|
||||||
endif
|
|
||||||
$(LD) $(LDFLAGS) $(LIBS) /out:$@ $(OBJ)
|
$(LD) $(LDFLAGS) $(LIBS) /out:$@ $(OBJ)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
endif # CONFIG_AWHTTPD
|
endif # CONFIG_AXHTTPD
|
||||||
|
|
||||||
clean::
|
clean::
|
||||||
-@rm -f $(TARGET)*
|
-@rm -f $(TARGET)*
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "ssl.h"
|
#include "ssl.h"
|
||||||
|
|
||||||
#define BACKLOG 15
|
#define BACKLOG 15
|
||||||
#define VERSION "3.0.7"
|
#define VERSION "1.0.0"
|
||||||
#ifdef CONFIG_HTTP_HAS_IPV6
|
#ifdef CONFIG_HTTP_HAS_IPV6
|
||||||
#define HAVE_IPV6
|
#define HAVE_IPV6
|
||||||
#endif
|
#endif
|
||||||
@ -47,10 +47,8 @@
|
|||||||
struct connstruct
|
struct connstruct
|
||||||
{
|
{
|
||||||
struct connstruct *next;
|
struct connstruct *next;
|
||||||
|
|
||||||
int state;
|
int state;
|
||||||
int reqtype;
|
int reqtype;
|
||||||
|
|
||||||
int networkdesc;
|
int networkdesc;
|
||||||
int filedesc;
|
int filedesc;
|
||||||
|
|
||||||
@ -73,7 +71,6 @@ struct connstruct
|
|||||||
char cgipathinfo[MAXREQUESTLENGTH];
|
char cgipathinfo[MAXREQUESTLENGTH];
|
||||||
#endif
|
#endif
|
||||||
char virtualhostreq[MAXREQUESTLENGTH];
|
char virtualhostreq[MAXREQUESTLENGTH];
|
||||||
|
|
||||||
int numbytes;
|
int numbytes;
|
||||||
char databuf[BLOCKSIZE];
|
char databuf[BLOCKSIZE];
|
||||||
|
|
||||||
@ -90,11 +87,13 @@ struct serverstruct
|
|||||||
SSLCTX *ssl_ctx;
|
SSLCTX *ssl_ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(CONFIG_HTTP_HAS_CGI)
|
||||||
struct cgiextstruct
|
struct cgiextstruct
|
||||||
{
|
{
|
||||||
struct cgiextstruct *next;
|
struct cgiextstruct *next;
|
||||||
char *ext;
|
char *ext;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
struct indexstruct
|
struct indexstruct
|
||||||
{
|
{
|
||||||
@ -106,7 +105,9 @@ struct indexstruct
|
|||||||
extern struct serverstruct *servers;
|
extern struct serverstruct *servers;
|
||||||
extern struct connstruct *usedconns;
|
extern struct connstruct *usedconns;
|
||||||
extern struct connstruct *freeconns;
|
extern struct connstruct *freeconns;
|
||||||
|
#if defined(CONFIG_HTTP_HAS_CGI)
|
||||||
extern struct cgiextstruct *cgiexts;
|
extern struct cgiextstruct *cgiexts;
|
||||||
|
#endif
|
||||||
extern struct indexstruct *indexlist;
|
extern struct indexstruct *indexlist;
|
||||||
|
|
||||||
// Conf global prototypes
|
// Conf global prototypes
|
||||||
@ -129,15 +130,6 @@ void procreadfile(struct connstruct *cn);
|
|||||||
void procsendfile(struct connstruct *cn);
|
void procsendfile(struct connstruct *cn);
|
||||||
int special_write(struct connstruct *cn, const uint8_t *buf, size_t count);
|
int special_write(struct connstruct *cn, const uint8_t *buf, size_t count);
|
||||||
|
|
||||||
// net.c prototypes
|
|
||||||
void addtoservers(int sd);
|
|
||||||
void selectloop(void);
|
|
||||||
|
|
||||||
// socket.c prototypes
|
|
||||||
void handlenewconnection(int listenfd, int is_ssl);
|
|
||||||
int openlistener(int port);
|
|
||||||
int openlistener6(int port);
|
|
||||||
|
|
||||||
// misc.c prototypes
|
// misc.c prototypes
|
||||||
void nada(int sigtype);
|
void nada(int sigtype);
|
||||||
void die(int sigtype);
|
void die(int sigtype);
|
||||||
|
266
httpd/main.c
266
httpd/main.c
@ -33,7 +33,12 @@ struct cgiextstruct *cgiexts;
|
|||||||
struct indexstruct *indexlist;
|
struct indexstruct *indexlist;
|
||||||
|
|
||||||
char *webroot = CONFIG_HTTP_WEBROOT;
|
char *webroot = CONFIG_HTTP_WEBROOT;
|
||||||
|
|
||||||
static void addindex(char *tp);
|
static void addindex(char *tp);
|
||||||
|
static void addtoservers(int sd);
|
||||||
|
static void selectloop(void);
|
||||||
|
static int openlistener(int port);
|
||||||
|
static void handlenewconnection(int listenfd, int is_ssl);
|
||||||
#if defined(CONFIG_HTTP_PERM_CHECK)
|
#if defined(CONFIG_HTTP_PERM_CHECK)
|
||||||
static void procpermcheck(char *pathtocheck);
|
static void procpermcheck(char *pathtocheck);
|
||||||
#endif
|
#endif
|
||||||
@ -123,7 +128,7 @@ int main(int argc, char *argv[])
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((tp=openlistener(CONFIG_HTTP_PORT)) == -1)
|
if ((tp = openlistener(CONFIG_HTTP_PORT)) == -1)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_HTTP_VERBOSE
|
#ifdef CONFIG_HTTP_VERBOSE
|
||||||
fprintf(stderr, "ERR: Couldn't bind to port %d (IPv4)\n",
|
fprintf(stderr, "ERR: Couldn't bind to port %d (IPv4)\n",
|
||||||
@ -143,7 +148,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((tp=openlistener(CONFIG_HTTP_HTTPS_PORT)) == -1)
|
if ((tp = openlistener(CONFIG_HTTP_HTTPS_PORT)) == -1)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_HTTP_VERBOSE
|
#ifdef CONFIG_HTTP_VERBOSE
|
||||||
fprintf(stderr, "ERR: Couldn't bind to port %d (IPv4)\n",
|
fprintf(stderr, "ERR: Couldn't bind to port %d (IPv4)\n",
|
||||||
@ -321,3 +326,260 @@ static void addcgiext(char *tp)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void addtoservers(int sd)
|
||||||
|
{
|
||||||
|
struct serverstruct *tp = (struct serverstruct *)
|
||||||
|
calloc(1, sizeof(struct serverstruct));
|
||||||
|
tp->next = servers;
|
||||||
|
tp->sd = sd;
|
||||||
|
servers = tp;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void selectloop(void)
|
||||||
|
{
|
||||||
|
fd_set rfds, wfds;
|
||||||
|
struct connstruct *tp, *to;
|
||||||
|
struct serverstruct *sp;
|
||||||
|
int rnum, wnum, active;
|
||||||
|
int currtime;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
// MAIN SELECT LOOP
|
||||||
|
FD_ZERO(&rfds);
|
||||||
|
FD_ZERO(&wfds);
|
||||||
|
rnum = wnum = -1;
|
||||||
|
|
||||||
|
// Add the listening sockets
|
||||||
|
sp = servers;
|
||||||
|
while (sp != NULL)
|
||||||
|
{
|
||||||
|
FD_SET(sp->sd, &rfds);
|
||||||
|
if (sp->sd > rnum) rnum = sp->sd;
|
||||||
|
sp = sp->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the established sockets
|
||||||
|
tp = usedconns;
|
||||||
|
currtime = time(NULL);
|
||||||
|
|
||||||
|
while (tp != NULL)
|
||||||
|
{
|
||||||
|
if (currtime > tp->timeout)
|
||||||
|
{
|
||||||
|
to = tp;
|
||||||
|
tp = tp->next;
|
||||||
|
removeconnection(to);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tp->state == STATE_WANT_TO_READ_HEAD)
|
||||||
|
{
|
||||||
|
FD_SET(tp->networkdesc, &rfds);
|
||||||
|
if (tp->networkdesc > rnum)
|
||||||
|
rnum = tp->networkdesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tp->state == STATE_WANT_TO_SEND_HEAD)
|
||||||
|
{
|
||||||
|
FD_SET(tp->networkdesc, &wfds);
|
||||||
|
if (tp->networkdesc > wnum)
|
||||||
|
wnum = tp->networkdesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tp->state == STATE_WANT_TO_READ_FILE)
|
||||||
|
{
|
||||||
|
FD_SET(tp->filedesc, &rfds);
|
||||||
|
if (tp->filedesc > rnum)
|
||||||
|
rnum = tp->filedesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tp->state == STATE_WANT_TO_SEND_FILE)
|
||||||
|
{
|
||||||
|
FD_SET(tp->networkdesc, &wfds);
|
||||||
|
if (tp->networkdesc > wnum)
|
||||||
|
wnum = tp->networkdesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(CONFIG_HTTP_DIRECTORIES)
|
||||||
|
if (tp->state == STATE_DOING_DIR)
|
||||||
|
{
|
||||||
|
FD_SET(tp->networkdesc, &wfds);
|
||||||
|
if (tp->networkdesc > wnum)
|
||||||
|
wnum = tp->networkdesc;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
tp = tp->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
active = select(wnum > rnum ? wnum+1 : rnum+1,
|
||||||
|
rnum != -1 ? &rfds : NULL,
|
||||||
|
wnum != -1 ? &wfds : NULL,
|
||||||
|
NULL, NULL);
|
||||||
|
|
||||||
|
// Handle the listening sockets
|
||||||
|
sp = servers;
|
||||||
|
while (active > 0 && sp != NULL)
|
||||||
|
{
|
||||||
|
if (FD_ISSET(sp->sd, &rfds))
|
||||||
|
{
|
||||||
|
handlenewconnection(sp->sd, sp->is_ssl);
|
||||||
|
active--;
|
||||||
|
}
|
||||||
|
|
||||||
|
sp = sp->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle the established sockets
|
||||||
|
tp = usedconns;
|
||||||
|
|
||||||
|
while (active > 0 && tp != NULL)
|
||||||
|
{
|
||||||
|
to = tp;
|
||||||
|
tp = tp->next;
|
||||||
|
|
||||||
|
if (to->state == STATE_WANT_TO_READ_HEAD)
|
||||||
|
if (FD_ISSET(to->networkdesc, &rfds))
|
||||||
|
{
|
||||||
|
active--;
|
||||||
|
procreadhead(to);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (to->state == STATE_WANT_TO_SEND_HEAD)
|
||||||
|
if (FD_ISSET(to->networkdesc, &wfds))
|
||||||
|
{
|
||||||
|
active--;
|
||||||
|
procsendhead(to);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (to->state == STATE_WANT_TO_READ_FILE)
|
||||||
|
if (FD_ISSET(to->filedesc, &rfds))
|
||||||
|
{
|
||||||
|
active--;
|
||||||
|
procreadfile(to);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (to->state == STATE_WANT_TO_SEND_FILE)
|
||||||
|
if (FD_ISSET(to->networkdesc, &wfds))
|
||||||
|
{
|
||||||
|
active--;
|
||||||
|
procsendfile(to);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(CONFIG_HTTP_DIRECTORIES)
|
||||||
|
if (to->state == STATE_DOING_DIR)
|
||||||
|
if (FD_ISSET(to->networkdesc, &wfds))
|
||||||
|
{
|
||||||
|
active--;
|
||||||
|
procdodir(to);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
} // MAIN SELECT LOOP
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
static void handlenewconnection(int listenfd, int is_ssl)
|
||||||
|
{
|
||||||
|
struct sockaddr_in6 their_addr;
|
||||||
|
int tp = sizeof(their_addr);
|
||||||
|
char ipbuf[100];
|
||||||
|
int connfd = accept(listenfd, (struct sockaddr *)&their_addr, &tp);
|
||||||
|
|
||||||
|
if (connfd == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (tp == sizeof(struct sockaddr_in6))
|
||||||
|
{
|
||||||
|
inet_ntop(AF_INET6, &their_addr.sin6_addr, ipbuf, sizeof(ipbuf));
|
||||||
|
}
|
||||||
|
else if (tp == sizeof(struct sockaddr_in))
|
||||||
|
{
|
||||||
|
inet_ntop(AF_INET, &(((struct sockaddr_in *)&their_addr)->sin_addr),
|
||||||
|
ipbuf, sizeof(ipbuf));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*ipbuf = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
addconnection(connfd, ipbuf, is_ssl);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
static void handlenewconnection(int listenfd, int is_ssl)
|
||||||
|
{
|
||||||
|
struct sockaddr_in their_addr;
|
||||||
|
int tp = sizeof(struct sockaddr_in);
|
||||||
|
int connfd = accept(listenfd, (struct sockaddr *)&their_addr, &tp);
|
||||||
|
|
||||||
|
if (connfd == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
addconnection(connfd, inet_ntoa(their_addr.sin_addr), is_ssl);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int openlistener(int port)
|
||||||
|
{
|
||||||
|
int sd;
|
||||||
|
#ifdef WIN32
|
||||||
|
char tp=1;
|
||||||
|
#else
|
||||||
|
int tp=1;
|
||||||
|
#endif
|
||||||
|
struct sockaddr_in my_addr;
|
||||||
|
|
||||||
|
if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &tp, sizeof(tp));
|
||||||
|
my_addr.sin_family = AF_INET; // host byte order
|
||||||
|
my_addr.sin_port = htons((short)port); // short, network byte order
|
||||||
|
my_addr.sin_addr.s_addr = INADDR_ANY; // automatically fill with my IP
|
||||||
|
memset(&(my_addr.sin_zero), 0, 8); // zero the rest of the struct
|
||||||
|
|
||||||
|
if (bind(sd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1)
|
||||||
|
{
|
||||||
|
close(sd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listen(sd, BACKLOG) == -1)
|
||||||
|
{
|
||||||
|
close(sd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sd;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
static int openlistener6(int port)
|
||||||
|
{
|
||||||
|
int sd,tp;
|
||||||
|
struct sockaddr_in6 my_addr;
|
||||||
|
|
||||||
|
if ((sd = socket(AF_INET6, SOCK_STREAM, 0)) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &tp, sizeof(tp));
|
||||||
|
memset(&my_addr, 0, sizeof(my_addr));
|
||||||
|
my_addr.sin6_family = AF_INET6;
|
||||||
|
my_addr.sin6_port = htons(port);
|
||||||
|
|
||||||
|
if (bind(sd, (struct sockaddr *)&my_addr, sizeof(my_addr)) == -1)
|
||||||
|
{
|
||||||
|
close(sd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listen(sd, BACKLOG) == -1)
|
||||||
|
{
|
||||||
|
close(sd);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sd;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -35,19 +35,23 @@ static mime_table_t mime_table[] =
|
|||||||
// Fundamentals
|
// Fundamentals
|
||||||
{ ".html", "text/html" },
|
{ ".html", "text/html" },
|
||||||
{ ".htm", "text/html" },
|
{ ".htm", "text/html" },
|
||||||
{ ".txt", "text/plain" },
|
{ ".css", "text/css" },
|
||||||
|
|
||||||
// Others
|
// Basic graphics
|
||||||
|
{ ".jpg", "image/jpeg" },
|
||||||
|
{ ".gif", "image/gif" },
|
||||||
|
{ ".png", "image/png" },
|
||||||
|
|
||||||
|
#ifdef CONFIG_HTTP_ALL_MIME_TYPES
|
||||||
|
// This list is a bit expensive to maintain normally, so it's an option.
|
||||||
|
{ ".txt", "text/plain" },
|
||||||
{ ".rtx", "text/richtext" },
|
{ ".rtx", "text/richtext" },
|
||||||
{ ".etx", "text/x-setext" },
|
{ ".etx", "text/x-setext" },
|
||||||
{ ".tsv", "text/tab-separated-values" },
|
{ ".tsv", "text/tab-separated-values" },
|
||||||
{ ".css", "text/css" },
|
|
||||||
{ ".xml", "text/xml" },
|
{ ".xml", "text/xml" },
|
||||||
{ ".dtd", "text/xml" },
|
{ ".dtd", "text/xml" },
|
||||||
{ ".gif", "image/gif" },
|
|
||||||
{ ".jpg", "image/jpeg" },
|
|
||||||
{ ".jpeg", "image/jpeg" },
|
|
||||||
{ ".jpe", "image/jpeg" },
|
{ ".jpe", "image/jpeg" },
|
||||||
|
{ ".jpeg", "image/jpeg" },
|
||||||
{ ".jfif", "image/jpeg" },
|
{ ".jfif", "image/jpeg" },
|
||||||
{ ".tif", "image/tiff" },
|
{ ".tif", "image/tiff" },
|
||||||
{ ".tiff", "image/tiff" },
|
{ ".tiff", "image/tiff" },
|
||||||
@ -59,7 +63,6 @@ static mime_table_t mime_table[] =
|
|||||||
{ ".xpm", "image/x-xpixmap" },
|
{ ".xpm", "image/x-xpixmap" },
|
||||||
{ ".xwd", "image/x-xwindowdump" },
|
{ ".xwd", "image/x-xwindowdump" },
|
||||||
{ ".ief", "image/ief" },
|
{ ".ief", "image/ief" },
|
||||||
{ ".png", "image/png" },
|
|
||||||
{ ".au", "audio/basic" },
|
{ ".au", "audio/basic" },
|
||||||
{ ".snd", "audio/basic" },
|
{ ".snd", "audio/basic" },
|
||||||
{ ".aif", "audio/x-aiff" },
|
{ ".aif", "audio/x-aiff" },
|
||||||
@ -159,6 +162,7 @@ static mime_table_t mime_table[] =
|
|||||||
{ ".tar.gz", "application/x-gzip" },
|
{ ".tar.gz", "application/x-gzip" },
|
||||||
{ ".bz2", "application/x-bzip2" },
|
{ ".bz2", "application/x-bzip2" },
|
||||||
{ ".zip", "application/zip" }
|
{ ".zip", "application/zip" }
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static int mime_cmp(const mime_table_t *t1, const mime_table_t *t2)
|
static int mime_cmp(const mime_table_t *t1, const mime_table_t *t2)
|
||||||
|
176
httpd/net.c
176
httpd/net.c
@ -1,176 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright(C) 2006 Cameron Rich
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "axhttp.h"
|
|
||||||
|
|
||||||
void addtoservers(int sd)
|
|
||||||
{
|
|
||||||
struct serverstruct *tp = (struct serverstruct *)
|
|
||||||
calloc(1, sizeof(struct serverstruct));
|
|
||||||
tp->next = servers;
|
|
||||||
tp->sd = sd;
|
|
||||||
servers = tp;
|
|
||||||
}
|
|
||||||
|
|
||||||
void selectloop()
|
|
||||||
{
|
|
||||||
fd_set rfds, wfds;
|
|
||||||
struct connstruct *tp, *to;
|
|
||||||
struct serverstruct *sp;
|
|
||||||
int rnum, wnum, active;
|
|
||||||
int currtime;
|
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
// MAIN SELECT LOOP
|
|
||||||
FD_ZERO(&rfds);
|
|
||||||
FD_ZERO(&wfds);
|
|
||||||
rnum = wnum = -1;
|
|
||||||
|
|
||||||
// Add the listening sockets
|
|
||||||
sp = servers;
|
|
||||||
while (sp != NULL)
|
|
||||||
{
|
|
||||||
FD_SET(sp->sd, &rfds);
|
|
||||||
if (sp->sd > rnum) rnum = sp->sd;
|
|
||||||
sp = sp->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the established sockets
|
|
||||||
tp = usedconns;
|
|
||||||
currtime = time(NULL);
|
|
||||||
|
|
||||||
while (tp != NULL)
|
|
||||||
{
|
|
||||||
if (currtime > tp->timeout)
|
|
||||||
{
|
|
||||||
to = tp;
|
|
||||||
tp = tp->next;
|
|
||||||
removeconnection(to);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tp->state == STATE_WANT_TO_READ_HEAD)
|
|
||||||
{
|
|
||||||
FD_SET(tp->networkdesc, &rfds);
|
|
||||||
if (tp->networkdesc > rnum)
|
|
||||||
rnum = tp->networkdesc;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tp->state == STATE_WANT_TO_SEND_HEAD)
|
|
||||||
{
|
|
||||||
FD_SET(tp->networkdesc, &wfds);
|
|
||||||
if (tp->networkdesc > wnum)
|
|
||||||
wnum = tp->networkdesc;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tp->state == STATE_WANT_TO_READ_FILE)
|
|
||||||
{
|
|
||||||
FD_SET(tp->filedesc, &rfds);
|
|
||||||
if (tp->filedesc > rnum)
|
|
||||||
rnum = tp->filedesc;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tp->state == STATE_WANT_TO_SEND_FILE)
|
|
||||||
{
|
|
||||||
FD_SET(tp->networkdesc, &wfds);
|
|
||||||
if (tp->networkdesc > wnum)
|
|
||||||
wnum = tp->networkdesc;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_HTTP_DIRECTORIES)
|
|
||||||
if (tp->state == STATE_DOING_DIR)
|
|
||||||
{
|
|
||||||
FD_SET(tp->networkdesc, &wfds);
|
|
||||||
if (tp->networkdesc > wnum)
|
|
||||||
wnum = tp->networkdesc;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
tp = tp->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
active = select(wnum > rnum ? wnum+1 : rnum+1,
|
|
||||||
rnum != -1 ? &rfds : NULL,
|
|
||||||
wnum != -1 ? &wfds : NULL,
|
|
||||||
NULL, NULL);
|
|
||||||
|
|
||||||
// Handle the listening sockets
|
|
||||||
sp = servers;
|
|
||||||
while (active > 0 && sp != NULL)
|
|
||||||
{
|
|
||||||
if (FD_ISSET(sp->sd, &rfds))
|
|
||||||
{
|
|
||||||
handlenewconnection(sp->sd, sp->is_ssl);
|
|
||||||
active--;
|
|
||||||
}
|
|
||||||
|
|
||||||
sp = sp->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle the established sockets
|
|
||||||
tp = usedconns;
|
|
||||||
|
|
||||||
while (active > 0 && tp != NULL)
|
|
||||||
{
|
|
||||||
to = tp;
|
|
||||||
tp = tp->next;
|
|
||||||
|
|
||||||
if (to->state == STATE_WANT_TO_READ_HEAD)
|
|
||||||
if (FD_ISSET(to->networkdesc, &rfds))
|
|
||||||
{
|
|
||||||
active--;
|
|
||||||
procreadhead(to);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (to->state == STATE_WANT_TO_SEND_HEAD)
|
|
||||||
if (FD_ISSET(to->networkdesc, &wfds))
|
|
||||||
{
|
|
||||||
active--;
|
|
||||||
procsendhead(to);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (to->state == STATE_WANT_TO_READ_FILE)
|
|
||||||
if (FD_ISSET(to->filedesc, &rfds))
|
|
||||||
{
|
|
||||||
active--;
|
|
||||||
procreadfile(to);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (to->state == STATE_WANT_TO_SEND_FILE)
|
|
||||||
if (FD_ISSET(to->networkdesc, &wfds))
|
|
||||||
{
|
|
||||||
active--;
|
|
||||||
procsendfile(to);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(CONFIG_HTTP_DIRECTORIES)
|
|
||||||
if (to->state == STATE_DOING_DIR)
|
|
||||||
if (FD_ISSET(to->networkdesc, &wfds))
|
|
||||||
{
|
|
||||||
active--;
|
|
||||||
procdodir(to);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
} // MAIN SELECT LOOP
|
|
||||||
}
|
|
89
httpd/proc.c
89
httpd/proc.c
@ -31,9 +31,11 @@ static void send301(struct connstruct *cn);
|
|||||||
static void send404(struct connstruct *cn);
|
static void send404(struct connstruct *cn);
|
||||||
static int procindex(struct connstruct *cn, struct stat *stp);
|
static int procindex(struct connstruct *cn, struct stat *stp);
|
||||||
static int hexit(char c);
|
static int hexit(char c);
|
||||||
static void urlencode(unsigned char *s, unsigned char *t);
|
|
||||||
static void urldecode(char *buf);
|
static void urldecode(char *buf);
|
||||||
|
|
||||||
|
#if defined(CONFIG_HTTP_DIRECTORIES)
|
||||||
|
static void urlencode(unsigned char *s, unsigned char *t);
|
||||||
|
#endif
|
||||||
#if defined(CONFIG_HTTP_HAS_CGI)
|
#if defined(CONFIG_HTTP_HAS_CGI)
|
||||||
static void proccgi(struct connstruct *cn, int has_pathinfo);
|
static void proccgi(struct connstruct *cn, int has_pathinfo);
|
||||||
#endif
|
#endif
|
||||||
@ -206,6 +208,35 @@ void procdodir(struct connstruct *cn)
|
|||||||
}
|
}
|
||||||
while (issockwriteable(cn->networkdesc));
|
while (issockwriteable(cn->networkdesc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Encode funny chars -> %xx in newly allocated storage */
|
||||||
|
/* (preserves '/' !) */
|
||||||
|
static void urlencode(unsigned char *s, unsigned char *t)
|
||||||
|
{
|
||||||
|
uint8_t *p, *tp;
|
||||||
|
|
||||||
|
tp =t ;
|
||||||
|
|
||||||
|
for (p=s; *p; p++)
|
||||||
|
{
|
||||||
|
if ((*p > 0x00 && *p < ',') ||
|
||||||
|
(*p > '9' && *p < 'A') ||
|
||||||
|
(*p > 'Z' && *p < '_') ||
|
||||||
|
(*p > '_' && *p < 'a') ||
|
||||||
|
(*p > 'z' && *p < 0xA1)) {
|
||||||
|
sprintf((char *)tp, "%%%02X", *p);
|
||||||
|
tp += 3;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*tp = *p;
|
||||||
|
tp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*tp='\0';
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void procreadhead(struct connstruct *cn)
|
void procreadhead(struct connstruct *cn)
|
||||||
@ -529,20 +560,6 @@ static int special_read(struct connstruct *cn, void *buf, size_t count)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send301(struct connstruct *cn)
|
|
||||||
{
|
|
||||||
char buf[2048];
|
|
||||||
sprintf(buf, "HTTP/1.1 301 Moved Permanently\nLocation: %s/\n\n<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<HTML><HEAD>\n<TITLE>301 Moved Permanently</TITLE>\n</HEAD><BODY>\n<H1>Moved Permanently</H1>\nThe document has moved <A HREF=\"%s/\">here</A>.<P>\n<HR>\n</BODY></HTML>\n", cn->filereq, cn->filereq);
|
|
||||||
special_write(cn, buf, strlen(buf));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void send404(struct connstruct *cn)
|
|
||||||
{
|
|
||||||
char buf[1024];
|
|
||||||
sprintf(buf, "HTTP/1.0 404 Not Found\nContent-Type: text/html\n\n<HTML><BODY>\n<TITLE>404 Not Found</TITLE><H1>It ain't there my friend. (404 Not Found)</H1>\n</BODY></HTML>\n");
|
|
||||||
special_write(cn, buf, strlen(buf));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns 0 if no index was found and doesn't modify cn->actualfile
|
// Returns 0 if no index was found and doesn't modify cn->actualfile
|
||||||
// Returns 1 if an index was found and puts the index in cn->actualfile
|
// Returns 1 if an index was found and puts the index in cn->actualfile
|
||||||
// and puts its stat info into stp
|
// and puts its stat info into stp
|
||||||
@ -701,34 +718,6 @@ static void proccgi(struct connstruct *cn, int has_pathinfo)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_HTTP_HAS_CGI */
|
#endif /* CONFIG_HTTP_HAS_CGI */
|
||||||
|
|
||||||
/* Encode funny chars -> %xx in newly allocated storage */
|
|
||||||
/* (preserves '/' !) */
|
|
||||||
static void urlencode(unsigned char *s, unsigned char *t)
|
|
||||||
{
|
|
||||||
uint8_t *p, *tp;
|
|
||||||
|
|
||||||
tp =t ;
|
|
||||||
|
|
||||||
for (p=s; *p; p++)
|
|
||||||
{
|
|
||||||
if ((*p > 0x00 && *p < ',') ||
|
|
||||||
(*p > '9' && *p < 'A') ||
|
|
||||||
(*p > 'Z' && *p < '_') ||
|
|
||||||
(*p > '_' && *p < 'a') ||
|
|
||||||
(*p > 'z' && *p < 0xA1)) {
|
|
||||||
sprintf((char *)tp, "%%%02X", *p);
|
|
||||||
tp += 3;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*tp = *p;
|
|
||||||
tp++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*tp='\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Decode string %xx -> char (in place) */
|
/* Decode string %xx -> char (in place) */
|
||||||
static void urldecode(char *buf)
|
static void urldecode(char *buf)
|
||||||
{
|
{
|
||||||
@ -778,3 +767,17 @@ static int hexit(char c)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void send301(struct connstruct *cn)
|
||||||
|
{
|
||||||
|
char buf[2048];
|
||||||
|
snprintf(buf, sizeof(buf), "HTTP/1.1 301 Moved Permanently\nLocation: %s/\n\n<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<HTML><HEAD>\n<TITLE>301 Moved Permanently</TITLE>\n</HEAD><BODY>\n<H1>Moved Permanently</H1>\nThe document has moved <A HREF=\"%s/\">here</A>.<P>\n<HR>\n</BODY></HTML>\n", cn->filereq, cn->filereq);
|
||||||
|
special_write(cn, buf, strlen(buf));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void send404(struct connstruct *cn)
|
||||||
|
{
|
||||||
|
char buf[1024];
|
||||||
|
sprintf(buf, "HTTP/1.0 404 Not Found\nContent-Type: text/html\n\n<HTML><BODY>\n<TITLE>404 Not Found</TITLE><H1>It ain't there my friend. (404 Not Found)</H1>\n</BODY></HTML>\n");
|
||||||
|
special_write(cn, buf, strlen(buf));
|
||||||
|
}
|
||||||
|
|
||||||
|
129
httpd/socket.c
129
httpd/socket.c
@ -1,129 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright(C) 2006 Cameron Rich
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "axhttp.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
|
|
||||||
void handlenewconnection(int listenfd, int is_ssl)
|
|
||||||
{
|
|
||||||
struct sockaddr_in6 their_addr;
|
|
||||||
int tp = sizeof(their_addr);
|
|
||||||
char ipbuf[100];
|
|
||||||
int connfd = accept(listenfd, (struct sockaddr *)&their_addr, &tp);
|
|
||||||
|
|
||||||
if (connfd == -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (tp == sizeof(struct sockaddr_in6))
|
|
||||||
{
|
|
||||||
inet_ntop(AF_INET6, &their_addr.sin6_addr, ipbuf, sizeof(ipbuf));
|
|
||||||
}
|
|
||||||
else if (tp == sizeof(struct sockaddr_in))
|
|
||||||
{
|
|
||||||
inet_ntop(AF_INET, &(((struct sockaddr_in *)&their_addr)->sin_addr),
|
|
||||||
ipbuf, sizeof(ipbuf));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*ipbuf = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
addconnection(connfd, ipbuf, is_ssl);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
void handlenewconnection(int listenfd, int is_ssl)
|
|
||||||
{
|
|
||||||
struct sockaddr_in their_addr;
|
|
||||||
int tp = sizeof(struct sockaddr_in);
|
|
||||||
int connfd = accept(listenfd, (struct sockaddr *)&their_addr, &tp);
|
|
||||||
|
|
||||||
if (connfd == -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
addconnection(connfd, inet_ntoa(their_addr.sin_addr), is_ssl);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int openlistener(int port)
|
|
||||||
{
|
|
||||||
int sd;
|
|
||||||
#ifdef WIN32
|
|
||||||
char tp=1;
|
|
||||||
#else
|
|
||||||
int tp=1;
|
|
||||||
#endif
|
|
||||||
struct sockaddr_in my_addr;
|
|
||||||
|
|
||||||
if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &tp, sizeof(tp));
|
|
||||||
my_addr.sin_family = AF_INET; // host byte order
|
|
||||||
my_addr.sin_port = htons((short)port); // short, network byte order
|
|
||||||
my_addr.sin_addr.s_addr = INADDR_ANY; // automatically fill with my IP
|
|
||||||
memset(&(my_addr.sin_zero), 0, 8); // zero the rest of the struct
|
|
||||||
|
|
||||||
if (bind(sd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1)
|
|
||||||
{
|
|
||||||
close(sd);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (listen(sd, BACKLOG) == -1)
|
|
||||||
{
|
|
||||||
close(sd);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sd;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
int openlistener6(int port)
|
|
||||||
{
|
|
||||||
int sd,tp;
|
|
||||||
struct sockaddr_in6 my_addr;
|
|
||||||
|
|
||||||
if ((sd = socket(AF_INET6, SOCK_STREAM, 0)) == -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &tp, sizeof(tp));
|
|
||||||
memset(&my_addr, 0, sizeof(my_addr));
|
|
||||||
my_addr.sin6_family = AF_INET6;
|
|
||||||
my_addr.sin6_port = htons(port);
|
|
||||||
|
|
||||||
if (bind(sd, (struct sockaddr *)&my_addr, sizeof(my_addr)) == -1)
|
|
||||||
{
|
|
||||||
close(sd);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (listen(sd, BACKLOG) == -1)
|
|
||||||
{
|
|
||||||
close(sd);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sd;
|
|
||||||
}
|
|
||||||
#endif
|
|
13
ssl/Makefile
13
ssl/Makefile
@ -31,7 +31,9 @@ endif
|
|||||||
ifndef CONFIG_PLATFORM_WIN32
|
ifndef CONFIG_PLATFORM_WIN32
|
||||||
TARGET1=../$(STAGE)/libaxtls.a
|
TARGET1=../$(STAGE)/libaxtls.a
|
||||||
BASETARGET=libaxtls.so
|
BASETARGET=libaxtls.so
|
||||||
TARGET2=../$(STAGE)/$(BASETARGET)
|
ifdef CONFIG_PLATFORM_CYGWIN
|
||||||
|
TARGET2=../$(STAGE)/libaxtls.dll.a
|
||||||
|
endif
|
||||||
|
|
||||||
# shared library major/minor numbers
|
# shared library major/minor numbers
|
||||||
LIBMAJOR=$(BASETARGET).1
|
LIBMAJOR=$(BASETARGET).1
|
||||||
@ -72,8 +74,15 @@ $(TARGET1) : $(OBJ)
|
|||||||
$(AR) -r $@ $(OBJ)
|
$(AR) -r $@ $(OBJ)
|
||||||
|
|
||||||
$(TARGET2) : $(OBJ)
|
$(TARGET2) : $(OBJ)
|
||||||
$(LD) $(LDFLAGS) -Wl,-soname,$(LIBMAJOR) $(LDSHARED) -o ../$(STAGE)/$(LIBMINOR) $(OBJ)
|
ifndef CONFIG_PLATFORM_CYGWIN
|
||||||
|
$(LD) $(LDFLAGS) $(LDSHARED) -Wl,-soname,$(LIBMAJOR) -o ../$(STAGE)/$(LIBMINOR) $(OBJ)
|
||||||
cd ../$(STAGE); ln -sf $(LIBMINOR) $(LIBMAJOR); ln -sf $(LIBMAJOR) $(BASETARGET); cd -
|
cd ../$(STAGE); ln -sf $(LIBMINOR) $(LIBMAJOR); ln -sf $(LIBMAJOR) $(BASETARGET); cd -
|
||||||
|
else
|
||||||
|
$(LD) $(LDFLAGS) $(LDSHARED) -o ../$(STAGE)/cygaxtls.dll \
|
||||||
|
-Wl,--out-implib=../$(STAGE)/libaxtls.dll.a \
|
||||||
|
-Wl,--export-all-symbols \
|
||||||
|
-Wl,--enable-auto-import $(OBJ)
|
||||||
|
endif
|
||||||
|
|
||||||
else # Win32
|
else # Win32
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user