summaryrefslogtreecommitdiff
path: root/nuttx/netutils
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-09-23 20:45:30 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-09-23 20:45:30 +0000
commit7326b1166b618ddc6b3eb9e9224b1f5ded5515a5 (patch)
treeaac340a4c4cc123213e08b83d1c452a67f333a35 /nuttx/netutils
parent1b15ed82bb5f48d8a03366af769331eac73c9993 (diff)
downloadpx4-nuttx-7326b1166b618ddc6b3eb9e9224b1f5ded5515a5.tar.gz
px4-nuttx-7326b1166b618ddc6b3eb9e9224b1f5ded5515a5.tar.bz2
px4-nuttx-7326b1166b618ddc6b3eb9e9224b1f5ded5515a5.zip
Partial implementation of accept() and listen()
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@354 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/netutils')
-rw-r--r--nuttx/netutils/Makefile25
-rw-r--r--nuttx/netutils/webserver/httpd.c61
2 files changed, 60 insertions, 26 deletions
diff --git a/nuttx/netutils/Makefile b/nuttx/netutils/Makefile
index 9c4536ff0..3232dd5f2 100644
--- a/nuttx/netutils/Makefile
+++ b/nuttx/netutils/Makefile
@@ -72,38 +72,39 @@ $(COBJS): %$(OBJEXT): %.c
$(CC) -c $(CFLAGS) $< -o $@
$(BIN): $(OBJS)
- ( for obj in $(OBJS) ; do \
+ @( for obj in $(OBJS) ; do \
$(AR) $@ $${obj} || \
{ echo "$(AR) $@ $obj FAILED!" ; exit 1 ; } ; \
done ; )
makestrings$(EXEEXT): uiplib/makestrings.c
- gcc -O2 -Wall -o makestrings$(EXEEXT) uiplib/makestrings.c
+ @gcc -O2 -Wall $< -o $@
.strings: makestrings$(EXEEXT) uiplib/netutil-strings
- ./makestrings uiplib/netutil-strings
+ @./makestrings uiplib/netutil-strings
+ @touch $@
Make.str: makestrings$(EXEEXT) uiplib/netutil-strings
- ./makestrings -s uiplib/netutil-strings >Make.str
+ @./makestrings -s uiplib/netutil-strings >Make.str
.depend: Makefile $(SRCS)
ifeq ($(CONFIG_NET),y)
- $(MKDEP) --dep-path . --dep-path uiplib --dep-path dhcpc --dep-path smtp --dep-path webclient \
+ @$(MKDEP) --dep-path . --dep-path uiplib --dep-path dhcpc --dep-path smtp --dep-path webclient \
--dep-path resolv --dep-path telnetd --dep-path webserver \
$(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
endif
- touch $@
+ @touch $@
depend: .strings Make.str .depend
clean:
- rm -f $(BIN) *.o *.rel *.asm *.lst *.sym *.adb *~
- rm -f uiplib/*~ dhcpc/*~ resolv/*~ smtp/*~ telnetd/*~ webclient/*~ webserver/*~
- if [ ! -z "$(OBJEXT)" ]; then rm -f *$(OBJEXT); fi
+ @rm -f $(BIN) *.o *.rel *.asm *.lst *.sym *.adb *~
+ @rm -f uiplib/*~ dhcpc/*~ resolv/*~ smtp/*~ telnetd/*~ webclient/*~ webserver/*~
+ @if [ ! -z "$(OBJEXT)" ]; then rm -f *$(OBJEXT); fi
distclean: clean
- rm -f Make.dep .depend
- rm -f $(STRNG_CSRCS) $(STRNG_ASRCS)
- rm -f Make.str netutil-strings.h makestrings$(EXEEXT)
+ @rm -f Make.dep .depend
+ @rm -f $(STRNG_CSRCS) $(STRNG_ASRCS)
+ @rm -f Make.str netutil-strings.h makestrings$(EXEEXT)
-include Make.dep
diff --git a/nuttx/netutils/webserver/httpd.c b/nuttx/netutils/webserver/httpd.c
index dfccdef6c..7c3271fd6 100644
--- a/nuttx/netutils/webserver/httpd.c
+++ b/nuttx/netutils/webserver/httpd.c
@@ -1,17 +1,24 @@
-/* httpd
+/****************************************************************************
+ * httpd
* httpd Web server
- * Author: Adam Dunkels <adam@sics.se>
*
- * The uIP web server is a very simplistic implementation of an HTTP
- * server. It can serve web pages and files from a read-only ROM
- * filesystem, and provides a very small scripting language.
+ * Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
- * Copyright (c) 2004, Adam Dunkels.
- * All rights reserved.
+ * This is a leverage of similar logic from uIP:
+ *
+ * Author: Adam Dunkels <adam@sics.se>
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved.
+ *
+ * The uIP web server is a very simplistic implementation of an HTTP
+ * server. It can serve web pages and files from a read-only ROM
+ * filesystem, and provides a very small scripting language.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
+ *
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
@@ -32,10 +39,15 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- */
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
#include <stdlib.h>
#include <sys/socket.h>
+#include <string.h>
#include <net/uip/uip.h>
#include <net/uip/httpd.h>
@@ -44,7 +56,9 @@
#include "httpd-cgi.h"
#include "netutil-strings.h"
-#include <string.h>
+/****************************************************************************
+ * Definitions
+ ****************************************************************************/
#define STATE_WAITING 0
#define STATE_OUTPUT 1
@@ -59,6 +73,10 @@
#define SEND_STR(psock, str) psock_send(psock, str, strlen(str))
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
static inline int send_file(struct httpd_state *pstate)
{
return send(pstate->sockout, pstate->file.data, pstate->file.len, 0);
@@ -256,16 +274,31 @@ static void handle_connection(struct httpd_state *pstate)
}
}
-void httpd_listen(void)
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+/****************************************************************************
+ * Name: httpd_listen
+ *
+ * Description:
+ * This is the main processing thread for the webserver. It never returns
+ * unless an error occurs
+ *
+ ****************************************************************************/
+
+int httpd_listen(void)
{
#warning "this is all very broken at the moment"
}
-/* Initialize the web server
+/****************************************************************************
+ * Name: httpd_init
+ *
+ * Description:
+ * This function initializes the web server and should be called at system
+ * boot-up.
*
- * This function initializes the web server and should be
- * called at system boot-up.
- */
+ ****************************************************************************/
void httpd_init(void)
{