From b351b752486c1693392faed106a8a77609006656 Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 31 Aug 2012 23:05:51 +0000 Subject: The content for uIP web server demo is no longer canned, but is not built dynameically (Thanks to Max Holtzberg) git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5073 42af7a65-404d-4744-a932-0658087f49c3 --- apps/examples/uip/Makefile | 10 ++- apps/examples/uip/cgi.c | 108 +++++++++++++++++++++++++++++++++ apps/examples/uip/cgi.h | 43 +++++++++++++ apps/examples/uip/httpd-fs/404.html | 8 +++ apps/examples/uip/httpd-fs/fade.png | Bin 0 -> 196 bytes apps/examples/uip/httpd-fs/files.shtml | 31 ++++++++++ apps/examples/uip/httpd-fs/footer.html | 3 + apps/examples/uip/httpd-fs/header.html | 16 +++++ apps/examples/uip/httpd-fs/index.shtml | 10 +++ apps/examples/uip/httpd-fs/stats.shtml | 31 ++++++++++ apps/examples/uip/httpd-fs/style.css | 92 ++++++++++++++++++++++++++++ apps/examples/uip/httpd-fs/tcp.shtml | 5 ++ apps/examples/uip/main.c | 5 +- 13 files changed, 358 insertions(+), 4 deletions(-) create mode 100644 apps/examples/uip/cgi.c create mode 100644 apps/examples/uip/cgi.h create mode 100644 apps/examples/uip/httpd-fs/404.html create mode 100644 apps/examples/uip/httpd-fs/fade.png create mode 100644 apps/examples/uip/httpd-fs/files.shtml create mode 100644 apps/examples/uip/httpd-fs/footer.html create mode 100644 apps/examples/uip/httpd-fs/header.html create mode 100644 apps/examples/uip/httpd-fs/index.shtml create mode 100644 apps/examples/uip/httpd-fs/stats.shtml create mode 100644 apps/examples/uip/httpd-fs/style.css create mode 100644 apps/examples/uip/httpd-fs/tcp.shtml (limited to 'apps/examples') diff --git a/apps/examples/uip/Makefile b/apps/examples/uip/Makefile index bf1d39917..4407998fc 100644 --- a/apps/examples/uip/Makefile +++ b/apps/examples/uip/Makefile @@ -1,8 +1,8 @@ ############################################################################ # apps/examples/uip/Makefile # -# Copyright (C) 2007-2008, 2010-2011 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt +# Copyright (C) 2007-2008, 2010-2012 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -40,7 +40,7 @@ include $(APPDIR)/Make.defs # uIP very tiny web server example ASRCS = -CSRCS = main.c +CSRCS = main.c cgi.c httpd_fsdata.c AOBJS = $(ASRCS:.S=$(OBJEXT)) COBJS = $(CSRCS:.c=$(OBJEXT)) @@ -75,6 +75,9 @@ $(COBJS): %$(OBJEXT): %.c done ; ) @touch .built +httpd_fsdata.c: httpd-fs/* + $(TOPDIR)/tools/mkfsdata.pl + context: .depend: Makefile $(SRCS) @@ -85,6 +88,7 @@ epend: .depend clean: @rm -f *.o *~ .*.swp .built + @rm -f httpd_fsdata.c $(call CLEAN) distclean: clean diff --git a/apps/examples/uip/cgi.c b/apps/examples/uip/cgi.c new file mode 100644 index 000000000..8d081db92 --- /dev/null +++ b/apps/examples/uip/cgi.c @@ -0,0 +1,108 @@ +/**************************************************************************** + * apps/examples/uip/cgi.c + * Web server script interface + * Author: Adam Dunkels + * + * Copyright (c) 2001-2006, Adam Dunkels. + * All rights reserved. + * + * 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 + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT 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 +#include +#include + +#include + +#include "cgi.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +#ifdef CONFIG_NETUTILS_HTTPDFILESTATS +HTTPD_CGI_CALL(file, "file-stats", file_stats); +#endif + +#ifdef CONFIG_NETUTILS_HTTPDNETSTATS +HTTPD_CGI_CALL(net, "net-stats", net_stats); +#endif + +/**************************************************************************** + * Name: net_stats + ****************************************************************************/ + +#ifdef CONFIG_NETUTILS_HTTPDNETSTATS +static void net_stats(struct httpd_state *pstate, char *ptr) +{ + char buffer[16]; + int i; + + for (i = 0; i < sizeof(uip_stat) / sizeof(uip_stats_t); i++) + { + snprintf(buffer, 16, "%5u\n", ((uip_stats_t *)&uip_stat)[i]); + send(pstate->ht_sockfd, buffer, strlen(buffer), 0); + } +} +#endif + +/**************************************************************************** + * Name: file_stats + ****************************************************************************/ + +#ifdef CONFIG_NETUTILS_HTTPDFILESTATS +static void file_stats(struct httpd_state *pstate, char *ptr) +{ + char buffer[16]; + char *pcount = strchr(ptr, ' ') + 1; + snprintf(buffer, 16, "%5u", httpd_fs_count(pcount)); + send(pstate->ht_sockfd, buffer, strlen(buffer), 0); +} +#endif + +/**************************************************************************** + * Name: cgi_register + ****************************************************************************/ + +void cgi_register() +{ +#ifdef CONFIG_NETUTILS_HTTPDFILESTATS + httpd_cgi_register(&file); +#endif + +#ifdef CONFIG_NETUTILS_HTTPDNETSTATS + httpd_cgi_register(&net); +#endif +} diff --git a/apps/examples/uip/cgi.h b/apps/examples/uip/cgi.h new file mode 100644 index 000000000..8ad0f93ce --- /dev/null +++ b/apps/examples/uip/cgi.h @@ -0,0 +1,43 @@ +/**************************************************************************** + * apps/examples/uip/cgi.c + * Web server script interface header file + * Author: Adam Dunkels + * + * Copyright (c) 2001, Adam Dunkels. + * All rights reserved. + * + * 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 + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT 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. + ****************************************************************************/ + +#ifndef __HTTPD_CGI_H__ +#define __HTTPD_CGI_H__ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +void cgi_register(void); + +#endif /* __HTTPD_CGI_H__ */ diff --git a/apps/examples/uip/httpd-fs/404.html b/apps/examples/uip/httpd-fs/404.html new file mode 100644 index 000000000..a17711d02 --- /dev/null +++ b/apps/examples/uip/httpd-fs/404.html @@ -0,0 +1,8 @@ + + +
+

404 - file not found

+

Go here instead.

+
+ + \ No newline at end of file diff --git a/apps/examples/uip/httpd-fs/fade.png b/apps/examples/uip/httpd-fs/fade.png new file mode 100644 index 000000000..a9e69f75d Binary files /dev/null and b/apps/examples/uip/httpd-fs/fade.png differ diff --git a/apps/examples/uip/httpd-fs/files.shtml b/apps/examples/uip/httpd-fs/files.shtml new file mode 100644 index 000000000..8a90dbd6d --- /dev/null +++ b/apps/examples/uip/httpd-fs/files.shtml @@ -0,0 +1,31 @@ +%!: /header.html +

File statistics

+
+ + + + + + + + + + + + + +
/index.shtml%! file-stats /index.shtml +
/files.shtml%! file-stats /files.shtml +
/stats.shtml%! file-stats /stats.shtml +
/style.css%! file-stats /style.css +
/404.html%! file-stats /404.html +
/fade.png%! file-stats /fade.png +
+
+%!: /footer.html diff --git a/apps/examples/uip/httpd-fs/footer.html b/apps/examples/uip/httpd-fs/footer.html new file mode 100644 index 000000000..5b6e2d653 --- /dev/null +++ b/apps/examples/uip/httpd-fs/footer.html @@ -0,0 +1,3 @@ + + + diff --git a/apps/examples/uip/httpd-fs/header.html b/apps/examples/uip/httpd-fs/header.html new file mode 100644 index 000000000..70df07fa6 --- /dev/null +++ b/apps/examples/uip/httpd-fs/header.html @@ -0,0 +1,16 @@ + + + + Welcome to the uIP web server! + + + + + + +
diff --git a/apps/examples/uip/httpd-fs/index.shtml b/apps/examples/uip/httpd-fs/index.shtml new file mode 100644 index 000000000..7f19358ce --- /dev/null +++ b/apps/examples/uip/httpd-fs/index.shtml @@ -0,0 +1,10 @@ +%!: /header.html +

+ These web pages are served by a small web server running on top of + the uIP embedded TCP/IP + stack. +

+

+ Click on the links above for web server statistics. +

+%!: /footer.html diff --git a/apps/examples/uip/httpd-fs/stats.shtml b/apps/examples/uip/httpd-fs/stats.shtml new file mode 100644 index 000000000..c63ed4afd --- /dev/null +++ b/apps/examples/uip/httpd-fs/stats.shtml @@ -0,0 +1,31 @@ +%!: /header.html +

Network statistics

+
+ +
+IP           Packets received
+             Packets sent
+	     Packets dropped
+IP errors    IP version/header length
+             IP length, high byte
+             IP length, low byte
+             IP fragments
+             Header checksum
+             Wrong protocol
+ICMP	     Packets received
+             Packets sent
+             Packets dropped
+             Type errors
+TCP          Packets received
+             Packets sent
+             Packets dropped
+             Checksum errors
+             Data packets without ACKs
+             Resets
+             Retransmissions
+	     No connection avaliable
+	     Connection attempts to closed ports
+
%! net-stats
+
+
+%!: /footer.html diff --git a/apps/examples/uip/httpd-fs/style.css b/apps/examples/uip/httpd-fs/style.css new file mode 100644 index 000000000..ba6df7f15 --- /dev/null +++ b/apps/examples/uip/httpd-fs/style.css @@ -0,0 +1,92 @@ +h1 +{ + text-align: center; + font-size:14pt; + font-family:arial,helvetica; + font-weight:bold; + padding:10px; +} + +body +{ + + background-color: #fffeec; + color:black; + + font-size:8pt; + font-family:arial,helvetica; +} + +.menu +{ + margin: 4px; + width:60%; + + padding:2px; + + border: solid 1px; + background-color: #fffcd2; + text-align:left; + + font-size:9pt; + font-family:arial,helvetica; +} + +div.menubox +{ + width: 25%; + border: 0; + float: left; +text-align: center; +} + +.contentblock +{ + margin: 4px; + width:60%; + + padding:2px; + + border: 1px dotted; + background-color: white; + + font-size:8pt; + font-family:arial,helvetica; + +} + +p.intro +{ + margin-left:20px; + margin-right:20px; + + font-size:10pt; +/* font-weight:bold; */ + font-family:arial,helvetica; +} + +p.clink +{ + font-size:12pt; + font-family:courier,monospace; + text-align:center; +} + +p.clink9 +{ + font-size:9pt; + font-family:courier,monospace; + text-align:center; +} + + +p +{ + padding-left:10px; +} + +p.right +{ + text-align:right; +} + diff --git a/apps/examples/uip/httpd-fs/tcp.shtml b/apps/examples/uip/httpd-fs/tcp.shtml new file mode 100644 index 000000000..4c4bffe97 --- /dev/null +++ b/apps/examples/uip/httpd-fs/tcp.shtml @@ -0,0 +1,5 @@ +%!: /header.html +

Current connections


+ +%! tcp-connections +%!: /footer.html \ No newline at end of file diff --git a/apps/examples/uip/main.c b/apps/examples/uip/main.c index 9593d4d25..dcad63eaa 100644 --- a/apps/examples/uip/main.c +++ b/apps/examples/uip/main.c @@ -1,7 +1,7 @@ /**************************************************************************** * examples/uip/main.c * - * Copyright (C) 2007, 2009-2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009-2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Based on uIP which also has a BSD style license: @@ -78,6 +78,8 @@ #include +#include "cgi.h" + /**************************************************************************** * Definitions ****************************************************************************/ @@ -192,6 +194,7 @@ int uip_main(int argc, char *argv[]) #ifdef CONFIG_NET_TCP printf("Starting webserver\n"); httpd_init(); + cgi_register(); httpd_listen(); #endif -- cgit v1.2.3
LocalRemoteStateRetransmissionsTimerFlags