Moved raw httpd and netio test apps from ports/msvc6 to apps

This commit is contained in:
goldsimon 2007-10-01 20:48:42 +00:00
parent a8aa89dcc2
commit fe5e7bd541
12 changed files with 1023 additions and 79 deletions

57
apps/httpserver_raw/fs.c Normal file
View File

@ -0,0 +1,57 @@
/*
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
* 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.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
#include "lwip/def.h"
#include "fs.h"
#include "fsdata.h"
#include "fsdata.c"
/*-----------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------*/
int
fs_open(char *name, struct fs_file *file)
{
struct fsdata_file_noconst *f;
for(f = (struct fsdata_file_noconst *)FS_ROOT;
f != NULL;
f = (struct fsdata_file_noconst *)f->next) {
if (!strcmp(name, (char *)f->name)) {
file->data = (char *)f->data;
file->len = f->len;
return 1;
}
}
return 0;
}
/*-----------------------------------------------------------------------------------*/

44
apps/httpserver_raw/fs.h Normal file
View File

@ -0,0 +1,44 @@
/*
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
* 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.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
#ifndef __FS_H__
#define __FS_H__
struct fs_file {
char *data;
int len;
};
/* file must be allocated by caller and will be filled in
by the function. */
int fs_open(char *name, struct fs_file *file);
#endif /* __FS_H__ */

View File

@ -0,0 +1,334 @@
static const unsigned char data_img_sics_gif[] = {
/* /img/sics.gif */
0x2f, 0x69, 0x6d, 0x67, 0x2f, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x67, 0x69, 0x66, 0,
0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32,
0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72,
0x76, 0x65, 0x72, 0x3a, 0x20, 0x6c, 0x77, 0x49, 0x50, 0x2f,
0x70, 0x72, 0x65, 0x2d, 0x30, 0x2e, 0x36, 0x20, 0x28, 0x68,
0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e,
0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61,
0x64, 0x61, 0x6d, 0x2f, 0x6c, 0x77, 0x69, 0x70, 0x2f, 0x29,
0xd, 0xa, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d,
0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67,
0x65, 0x2f, 0x67, 0x69, 0x66, 0xd, 0xa, 0xd, 0xa, 0x47,
0x49, 0x46, 0x38, 0x39, 0x61, 0x46, 00, 0x22, 00, 0xa5,
00, 00, 0xd9, 0x2b, 0x39, 0x6a, 0x6a, 0x6a, 0xbf, 0xbf,
0xbf, 0x93, 0x93, 0x93, 0xf, 0xf, 0xf, 0xb0, 0xb0, 0xb0,
0xa6, 0xa6, 0xa6, 0x80, 0x80, 0x80, 0x76, 0x76, 0x76, 0x1e,
0x1e, 0x1e, 0x9d, 0x9d, 0x9d, 0x2e, 0x2e, 0x2e, 0x49, 0x49,
0x49, 0x54, 0x54, 0x54, 0x8a, 0x8a, 0x8a, 0x60, 0x60, 0x60,
0xc6, 0xa6, 0x99, 0xbd, 0xb5, 0xb2, 0xc2, 0xab, 0xa1, 0xd9,
0x41, 0x40, 0xd5, 0x67, 0x55, 0xc0, 0xb0, 0xaa, 0xd5, 0x5e,
0x4e, 0xd6, 0x50, 0x45, 0xcc, 0x93, 0x7d, 0xc8, 0xa1, 0x90,
0xce, 0x8b, 0x76, 0xd2, 0x7b, 0x65, 0xd1, 0x84, 0x6d, 0xc9,
0x99, 0x86, 0x3a, 0x3a, 0x3a, 00, 00, 00, 0xb8, 0xb8,
0xb8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x2c, 00, 00, 00, 00, 0x46,
00, 0x22, 00, 00, 0x6, 0xfe, 0x40, 0x90, 0x70, 0x48,
0x2c, 0x1a, 0x8f, 0xc8, 0xa4, 0x72, 0xc9, 0x6c, 0x3a, 0x9f,
0xd0, 0xa8, 0x74, 0x4a, 0xad, 0x5a, 0xaf, 0xd8, 0xac, 0x76,
0xa9, 0x40, 0x4, 0xbe, 0x83, 0xe2, 0x60, 0x3c, 0x50, 0x20,
0xd, 0x8e, 0x6f, 00, 0x31, 0x28, 0x1c, 0xd, 0x7, 0xb5,
0xc3, 0x60, 0x75, 0x24, 0x3e, 0xf8, 0xfc, 0x87, 0x11, 0x6,
0xe9, 0x3d, 0x46, 0x7, 0xb, 0x7a, 0x7a, 0x7c, 0x43, 0x6,
0x1e, 0x84, 0x78, 0xb, 0x7, 0x6e, 0x51, 0x1, 0x8a, 0x84,
0x8, 0x7e, 0x79, 0x80, 0x87, 0x89, 0x91, 0x7a, 0x93, 0xa,
0x4, 0x99, 0x78, 0x96, 0x4f, 0x3, 0x9e, 0x79, 0x1, 0x94,
0x9f, 0x43, 0x9c, 0xa3, 0xa4, 0x5, 0x77, 0xa3, 0xa0, 0x4e,
0x98, 0x79, 0xb, 0x1e, 0x83, 0xa4, 0xa6, 0x1f, 0x96, 0x5,
0x9d, 0xaa, 0x78, 0x1, 0x7, 0x84, 0x4, 0x1e, 0x1e, 0xbb,
0xb8, 0x51, 0x84, 0xe, 0x43, 0x5, 0x7, 0x77, 0xa5, 0x7f,
0x42, 0xb1, 0xb2, 0x1, 0x63, 0x8, 0xd, 0xbb, 0x1, 0xc,
0x7a, 0xd, 0x44, 0xe, 0xd8, 0xaf, 0x4c, 0x5, 0x7a, 0x4,
0x47, 0x7, 0x7, 0xb7, 0x80, 0xa2, 0xe1, 0x7d, 0x44, 0x5,
0x1, 0x4, 0x1, 0xd0, 0xea, 0x87, 0x93, 0x4f, 0xe0, 0x9a,
0x49, 0xce, 0xd8, 0x79, 0x4, 0x66, 0x20, 0x15, 0x10, 0x10,
0x11, 0x92, 0x29, 0x80, 0xb6, 0xc0, 0x91, 0x15, 0x45, 0x1e,
0x90, 0x19, 0x71, 0x46, 0xa8, 0x5c, 0x4, 0xe, 00, 0x22,
0x4e, 0xe8, 0x40, 0x24, 0x9f, 0x3e, 0x4, 0x6, 0xa7, 0x58,
0xd4, 0x93, 0xa0, 0x1c, 0x91, 0x3f, 0xe8, 0xf0, 0x88, 0x3,
0xb1, 0x21, 0xa2, 0x49, 00, 0x19, 0x86, 0xfc, 0x52, 0x44,
0xe0, 0x1, 0x9d, 0x29, 0x21, 0x15, 0x25, 0x50, 0xf7, 0x67,
0x25, 0x1e, 0x6, 0xfd, 0x4e, 0x9a, 0xb4, 0x90, 0xac, 0x15,
0xfa, 0xcb, 0x52, 0x53, 0x1e, 0x8c, 0xf2, 0xf8, 0x7, 0x92,
0x2d, 0x8, 0x3a, 0x4d, 0x12, 0x49, 0x95, 0x49, 0xdb, 0x14,
0x4, 0xc4, 0x14, 0x85, 0x29, 0xaa, 0xe7, 0x1, 0x8, 0xa4,
0x49, 0x1, 0x14, 0x51, 0xe0, 0x53, 0x91, 0xd5, 0x29, 0x6,
0x1a, 0x64, 0x2, 0xf4, 0xc7, 0x81, 0x9e, 0x5, 0x20, 0x22,
0x64, 0xa5, 0x30, 0xae, 0xab, 0x9e, 0x97, 0x53, 0xd8, 0xb9,
0xfd, 0x50, 0xef, 0x93, 0x2, 0x42, 0x74, 0x34, 0xe8, 0x9c,
0x20, 0x21, 0xc9, 0x1, 0x68, 0x78, 0xe6, 0x55, 0x29, 0x20,
0x56, 0x4f, 0x4c, 0x40, 0x51, 0x71, 0x82, 0xc0, 0x70, 0x21,
0x22, 0x85, 0xbe, 0x4b, 0x1c, 0x44, 0x5, 0xea, 0xa4, 0x1,
0xbf, 0x22, 0xb5, 0xf0, 0x1c, 0x6, 0x51, 0x38, 0x8f, 0xe0,
0x22, 0xec, 0x18, 0xac, 0x39, 0x22, 0xd4, 0xd6, 0x93, 0x44,
0x1, 0x32, 0x82, 0xc8, 0xfc, 0x61, 0xb3, 0x1, 0x45, 0xc,
0x2e, 0x83, 0x30, 0xd0, 0xe, 0x17, 0x24, 0xf, 0x70, 0x85,
0x94, 0xee, 0x5, 0x5, 0x53, 0x4b, 0x32, 0x1b, 0x3f, 0x98,
0xd3, 0x1d, 0x29, 0x81, 0xb0, 0xae, 0x1e, 0x8c, 0x7e, 0x68,
0xe0, 0x60, 0x5a, 0x54, 0x8f, 0xb0, 0x78, 0x69, 0x73, 0x6,
0xa2, 00, 0x6b, 0x57, 0xca, 0x3d, 0x11, 0x50, 0xbd, 0x4,
0x30, 0x4b, 0x3a, 0xd4, 0xab, 0x5f, 0x1f, 0x9b, 0x3d, 0x13,
0x74, 0x27, 0x88, 0x3c, 0x25, 0xe0, 0x17, 0xbe, 0x7a, 0x79,
0x45, 0xd, 0xc, 0xb0, 0x8b, 0xda, 0x90, 0xca, 0x80, 0x6,
0x5d, 0x17, 0x60, 0x1c, 0x22, 0x4c, 0xd8, 0x57, 0x22, 0x6,
0x20, 00, 0x98, 0x7, 0x8, 0xe4, 0x56, 0x80, 0x80, 0x1c,
0xc5, 0xb7, 0xc5, 0x82, 0xc, 0x36, 0xe8, 0xe0, 0x83, 0x10,
0x46, 0x28, 0xe1, 0x84, 0x14, 0x56, 0x68, 0xa1, 0x10, 0x41,
00, 00, 0x3b, };
static const unsigned char data_404_html[] = {
/* /404.html */
0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x34,
0x30, 0x34, 0x20, 0x46, 0x69, 0x6c, 0x65, 0x20, 0x6e, 0x6f,
0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0xd, 0xa, 0x53,
0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x6c, 0x77, 0x49,
0x50, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x30, 0x2e, 0x36, 0x20,
0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77,
0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f,
0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x6c, 0x77, 0x69, 0x70,
0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e,
0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65,
0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd,
0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x3c, 0x68,
0x65, 0x61, 0x64, 0x3e, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65,
0x3e, 0x6c, 0x77, 0x49, 0x50, 0x20, 0x2d, 0x20, 0x41, 0x20,
0x4c, 0x69, 0x67, 0x68, 0x74, 0x77, 0x65, 0x69, 0x67, 0x68,
0x74, 0x20, 0x54, 0x43, 0x50, 0x2f, 0x49, 0x50, 0x20, 0x53,
0x74, 0x61, 0x63, 0x6b, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c,
0x65, 0x3e, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x3e, 0xa,
0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f,
0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65,
0x22, 0x20, 0x74, 0x65, 0x78, 0x74, 0x3d, 0x22, 0x62, 0x6c,
0x61, 0x63, 0x6b, 0x22, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x20,
0x20, 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69,
0x64, 0x74, 0x68, 0x3d, 0x22, 0x31, 0x30, 0x30, 0x25, 0x22,
0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x74,
0x72, 0x20, 0x76, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3d, 0x22,
0x74, 0x6f, 0x70, 0x22, 0x3e, 0x3c, 0x74, 0x64, 0x20, 0x77,
0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 0x38, 0x30, 0x22, 0x3e,
0x9, 0x20, 0x20, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x61, 0x20,
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70,
0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63,
0x73, 0x2e, 0x73, 0x65, 0x2f, 0x22, 0x3e, 0x3c, 0x69, 0x6d,
0x67, 0x20, 0x73, 0x72, 0x63, 0x3d, 0x22, 0x69, 0x6d, 0x67,
0x2f, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x67, 0x69, 0x66, 0x22,
0xa, 0x9, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72,
0x3d, 0x22, 0x30, 0x22, 0x20, 0x61, 0x6c, 0x74, 0x3d, 0x22,
0x53, 0x49, 0x43, 0x53, 0x20, 0x6c, 0x6f, 0x67, 0x6f, 0x22,
0x20, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3d, 0x22, 0x53, 0x49,
0x43, 0x53, 0x20, 0x6c, 0x6f, 0x67, 0x6f, 0x22, 0x3e, 0x3c,
0x2f, 0x61, 0x3e, 0xa, 0x9, 0x3c, 0x2f, 0x74, 0x64, 0x3e,
0x3c, 0x74, 0x64, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d,
0x22, 0x35, 0x30, 0x30, 0x22, 0x3e, 0x9, 0x20, 0x20, 0xa,
0x9, 0x20, 0x20, 0x3c, 0x68, 0x31, 0x3e, 0x6c, 0x77, 0x49,
0x50, 0x20, 0x2d, 0x20, 0x41, 0x20, 0x4c, 0x69, 0x67, 0x68,
0x74, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x20, 0x54, 0x43,
0x50, 0x2f, 0x49, 0x50, 0x20, 0x53, 0x74, 0x61, 0x63, 0x6b,
0x3c, 0x2f, 0x68, 0x31, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x3c,
0x68, 0x32, 0x3e, 0x34, 0x30, 0x34, 0x20, 0x2d, 0x20, 0x50,
0x61, 0x67, 0x65, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x66, 0x6f,
0x75, 0x6e, 0x64, 0x3c, 0x2f, 0x68, 0x32, 0x3e, 0xa, 0x9,
0x20, 0x20, 0x3c, 0x70, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20,
0x20, 0x53, 0x6f, 0x72, 0x72, 0x79, 0x2c, 0x20, 0x74, 0x68,
0x65, 0x20, 0x70, 0x61, 0x67, 0x65, 0x20, 0x79, 0x6f, 0x75,
0x20, 0x61, 0x72, 0x65, 0x20, 0x72, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x77, 0x61, 0x73, 0x20,
0x6e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x20,
0x6f, 0x6e, 0x20, 0x74, 0x68, 0x69, 0x73, 0xa, 0x9, 0x20,
0x20, 0x20, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e,
0x20, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa,
0x9, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, 0x3e,
0xa, 0x9, 0x20, 0x20, 0x26, 0x6e, 0x62, 0x73, 0x70, 0x3b,
0xa, 0x9, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74,
0x72, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c,
0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0xa, 0x3c, 0x2f,
0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68, 0x74,
0x6d, 0x6c, 0x3e, 0xa, };
static const unsigned char data_index_html[] = {
/* /index.html */
0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32,
0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72,
0x76, 0x65, 0x72, 0x3a, 0x20, 0x6c, 0x77, 0x49, 0x50, 0x2f,
0x70, 0x72, 0x65, 0x2d, 0x30, 0x2e, 0x36, 0x20, 0x28, 0x68,
0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e,
0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61,
0x64, 0x61, 0x6d, 0x2f, 0x6c, 0x77, 0x69, 0x70, 0x2f, 0x29,
0xd, 0xa, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d,
0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74,
0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd, 0xa, 0x3c,
0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x3c, 0x68, 0x65, 0x61,
0x64, 0x3e, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x6c,
0x77, 0x49, 0x50, 0x20, 0x2d, 0x20, 0x41, 0x20, 0x4c, 0x69,
0x67, 0x68, 0x74, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x20,
0x54, 0x43, 0x50, 0x2f, 0x49, 0x50, 0x20, 0x53, 0x74, 0x61,
0x63, 0x6b, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e,
0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x3e, 0xa, 0x3c, 0x62,
0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, 0x6c, 0x6f,
0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65, 0x22, 0x20,
0x74, 0x65, 0x78, 0x74, 0x3d, 0x22, 0x62, 0x6c, 0x61, 0x63,
0x6b, 0x22, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c,
0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74,
0x68, 0x3d, 0x22, 0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x74, 0x72, 0x20,
0x76, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3d, 0x22, 0x74, 0x6f,
0x70, 0x22, 0x3e, 0x3c, 0x74, 0x64, 0x20, 0x77, 0x69, 0x64,
0x74, 0x68, 0x3d, 0x22, 0x38, 0x30, 0x22, 0x3e, 0x9, 0x20,
0x20, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72,
0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e,
0x73, 0x65, 0x2f, 0x22, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20,
0x73, 0x72, 0x63, 0x3d, 0x22, 0x69, 0x6d, 0x67, 0x2f, 0x73,
0x69, 0x63, 0x73, 0x2e, 0x67, 0x69, 0x66, 0x22, 0xa, 0x9,
0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3d, 0x22,
0x30, 0x22, 0x20, 0x61, 0x6c, 0x74, 0x3d, 0x22, 0x53, 0x49,
0x43, 0x53, 0x20, 0x6c, 0x6f, 0x67, 0x6f, 0x22, 0x20, 0x74,
0x69, 0x74, 0x6c, 0x65, 0x3d, 0x22, 0x53, 0x49, 0x43, 0x53,
0x20, 0x6c, 0x6f, 0x67, 0x6f, 0x22, 0x3e, 0x3c, 0x2f, 0x61,
0x3e, 0xa, 0x9, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74,
0x64, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 0x35,
0x30, 0x30, 0x22, 0x3e, 0x9, 0x20, 0x20, 0xa, 0x9, 0x20,
0x20, 0x3c, 0x68, 0x31, 0x3e, 0x6c, 0x77, 0x49, 0x50, 0x20,
0x2d, 0x20, 0x41, 0x20, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x77,
0x65, 0x69, 0x67, 0x68, 0x74, 0x20, 0x54, 0x43, 0x50, 0x2f,
0x49, 0x50, 0x20, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x3c, 0x2f,
0x68, 0x31, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x70, 0x3e,
0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x54, 0x68, 0x65, 0x20,
0x77, 0x65, 0x62, 0x20, 0x70, 0x61, 0x67, 0x65, 0x20, 0x79,
0x6f, 0x75, 0x20, 0x61, 0x72, 0x65, 0x20, 0x77, 0x61, 0x74,
0x63, 0x68, 0x69, 0x6e, 0x67, 0x20, 0x77, 0x61, 0x73, 0x20,
0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20,
0x61, 0x20, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x77,
0x65, 0x62, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x73, 0x65,
0x72, 0x76, 0x65, 0x72, 0x20, 0x72, 0x75, 0x6e, 0x6e, 0x69,
0x6e, 0x67, 0x20, 0x6f, 0x6e, 0x20, 0x74, 0x6f, 0x70, 0x20,
0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6c, 0x69, 0x67,
0x68, 0x74, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x20, 0x54,
0x43, 0x50, 0x2f, 0x49, 0x50, 0x20, 0x73, 0x74, 0x61, 0x63,
0x6b, 0x20, 0x3c, 0x61, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20,
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70,
0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63,
0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d,
0x2f, 0x6c, 0x77, 0x69, 0x70, 0x2f, 0x22, 0x3e, 0x6c, 0x77,
0x49, 0x50, 0x3c, 0x2f, 0x61, 0x3e, 0x2e, 0xa, 0x9, 0x20,
0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x3c,
0x70, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x77,
0x49, 0x50, 0x20, 0x69, 0x73, 0x20, 0x61, 0x6e, 0x20, 0x6f,
0x70, 0x65, 0x6e, 0x20, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
0x20, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6f, 0x66, 0x20, 0x74,
0x68, 0x65, 0x20, 0x54, 0x43, 0x50, 0x2f, 0x49, 0x50, 0xa,
0x9, 0x20, 0x20, 0x20, 0x20, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x63, 0x6f, 0x6c, 0x20, 0x73, 0x75, 0x69, 0x74, 0x65, 0x20,
0x74, 0x68, 0x61, 0x74, 0x20, 0x77, 0x61, 0x73, 0x20, 0x6f,
0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x6c, 0x79, 0x20,
0x77, 0x72, 0x69, 0x74, 0x74, 0x65, 0x6e, 0x20, 0x62, 0x79,
0x20, 0x41, 0x64, 0x61, 0x6d, 0x20, 0x44, 0x75, 0x6e, 0x6b,
0x65, 0x6c, 0x73, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x6f,
0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x53, 0x77, 0x65, 0x64,
0x69, 0x73, 0x68, 0x20, 0x49, 0x6e, 0x73, 0x74, 0x69, 0x74,
0x75, 0x74, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x43, 0x6f, 0x6d,
0x70, 0x75, 0x74, 0x65, 0x72, 0x20, 0x53, 0x63, 0x69, 0x65,
0x6e, 0x63, 0x65, 0x20, 0x62, 0x75, 0x74, 0x20, 0x6e, 0x6f,
0x77, 0x20, 0x69, 0x73, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20,
0x62, 0x65, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x63, 0x74, 0x69,
0x76, 0x65, 0x6c, 0x79, 0x20, 0x64, 0x65, 0x76, 0x65, 0x6c,
0x6f, 0x70, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x61, 0x20,
0x74, 0x65, 0x61, 0x6d, 0x20, 0x6f, 0x66, 0x20, 0x64, 0x65,
0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x73, 0xa, 0x9,
0x20, 0x20, 0x20, 0x20, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69,
0x62, 0x75, 0x74, 0x65, 0x64, 0x20, 0x77, 0x6f, 0x72, 0x6c,
0x64, 0x2d, 0x77, 0x69, 0x64, 0x65, 0x2e, 0x20, 0x53, 0x69,
0x6e, 0x63, 0x65, 0x20, 0x69, 0x74, 0x27, 0x73, 0x20, 0x72,
0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2c, 0x20, 0x6c, 0x77,
0x49, 0x50, 0x20, 0x68, 0x61, 0x73, 0xa, 0x9, 0x20, 0x20,
0x20, 0x20, 0x73, 0x70, 0x75, 0x72, 0x72, 0x65, 0x64, 0x20,
0x61, 0x20, 0x6c, 0x6f, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x69,
0x6e, 0x74, 0x65, 0x72, 0x65, 0x73, 0x74, 0x20, 0x61, 0x6e,
0x64, 0x20, 0x68, 0x61, 0x73, 0x20, 0x62, 0x65, 0x65, 0x6e,
0x20, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x20, 0x74, 0x6f,
0x20, 0x73, 0x65, 0x76, 0x65, 0x72, 0x61, 0x6c, 0xa, 0x9,
0x20, 0x20, 0x20, 0x20, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f,
0x72, 0x6d, 0x73, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x6f, 0x70,
0x65, 0x72, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x73, 0x79,
0x73, 0x74, 0x65, 0x6d, 0x73, 0x2e, 0x20, 0x6c, 0x77, 0x49,
0x50, 0x20, 0x63, 0x61, 0x6e, 0x20, 0x62, 0x65, 0x20, 0x75,
0x73, 0x65, 0x64, 0x20, 0x65, 0x69, 0x74, 0x68, 0x65, 0x72,
0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x77, 0x69, 0x74, 0x68,
0x20, 0x6f, 0x72, 0x20, 0x77, 0x69, 0x74, 0x68, 0x6f, 0x75,
0x74, 0x20, 0x61, 0x6e, 0x20, 0x75, 0x6e, 0x64, 0x65, 0x72,
0x6c, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x4f, 0x53, 0x2e, 0xa,
0x9, 0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa, 0x9, 0x20,
0x20, 0x3c, 0x70, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20,
0x54, 0x68, 0x65, 0x20, 0x66, 0x6f, 0x63, 0x75, 0x73, 0x20,
0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6c, 0x77, 0x49,
0x50, 0x20, 0x54, 0x43, 0x50, 0x2f, 0x49, 0x50, 0x20, 0x69,
0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x20, 0x69, 0x73, 0x20, 0x74, 0x6f, 0x20,
0x72, 0x65, 0x64, 0x75, 0x63, 0x65, 0xa, 0x9, 0x20, 0x20,
0x20, 0x20, 0x74, 0x68, 0x65, 0x20, 0x52, 0x41, 0x4d, 0x20,
0x75, 0x73, 0x61, 0x67, 0x65, 0x20, 0x77, 0x68, 0x69, 0x6c,
0x65, 0x20, 0x73, 0x74, 0x69, 0x6c, 0x6c, 0x20, 0x68, 0x61,
0x76, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x20, 0x66, 0x75, 0x6c,
0x6c, 0x20, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x20, 0x54, 0x43,
0x50, 0x2e, 0x20, 0x54, 0x68, 0x69, 0x73, 0xa, 0x9, 0x20,
0x20, 0x20, 0x20, 0x6d, 0x61, 0x6b, 0x65, 0x73, 0x20, 0x6c,
0x77, 0x49, 0x50, 0x20, 0x73, 0x75, 0x69, 0x74, 0x61, 0x62,
0x6c, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x75, 0x73, 0x65,
0x20, 0x69, 0x6e, 0x20, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x64,
0x65, 0x64, 0x20, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x73,
0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x74, 0x65, 0x6e, 0x73,
0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x66, 0x20, 0x6b,
0x69, 0x6c, 0x6f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x20, 0x6f,
0x66, 0x20, 0x66, 0x72, 0x65, 0x65, 0x20, 0x52, 0x41, 0x4d,
0x20, 0x61, 0x6e, 0x64, 0x20, 0x72, 0x6f, 0x6f, 0x6d, 0x20,
0x66, 0x6f, 0x72, 0x20, 0x61, 0x72, 0x6f, 0x75, 0x6e, 0x64,
0x20, 0x34, 0x30, 0x20, 0x6b, 0x69, 0x6c, 0x6f, 0x62, 0x79,
0x74, 0x65, 0x73, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x6f,
0x66, 0x20, 0x63, 0x6f, 0x64, 0x65, 0x20, 0x52, 0x4f, 0x4d,
0x2e, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa,
0x9, 0x20, 0x20, 0x3c, 0x70, 0x3e, 0xa, 0x9, 0x20, 0x20,
0x20, 0x20, 0x4d, 0x6f, 0x72, 0x65, 0x20, 0x69, 0x6e, 0x66,
0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61,
0x62, 0x6f, 0x75, 0x74, 0x20, 0x6c, 0x77, 0x49, 0x50, 0x20,
0x63, 0x61, 0x6e, 0x20, 0x62, 0x65, 0x20, 0x66, 0x6f, 0x75,
0x6e, 0x64, 0x20, 0x61, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20,
0x6c, 0x77, 0x49, 0x50, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20,
0x68, 0x6f, 0x6d, 0x65, 0x70, 0x61, 0x67, 0x65, 0x20, 0x61,
0x74, 0x20, 0x3c, 0x61, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20,
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70,
0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63,
0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d,
0x2f, 0x6c, 0x77, 0x69, 0x70, 0x2f, 0x22, 0x3e, 0x68, 0x74,
0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73,
0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64,
0x61, 0x6d, 0x2f, 0x6c, 0x77, 0x69, 0x70, 0x2f, 0x3c, 0x2f,
0x61, 0x3e, 0x2e, 0xa, 0x9, 0x20, 0x20, 0x3c, 0x2f, 0x70,
0x3e, 0xa, 0x9, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74,
0x64, 0x3e, 0xa, 0x9, 0x20, 0x20, 0x26, 0x6e, 0x62, 0x73,
0x70, 0x3b, 0xa, 0x9, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c,
0x2f, 0x74, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0xa,
0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa, 0x3c, 0x2f,
0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0xa, };
const struct fsdata_file file_img_sics_gif[] = {{NULL, data_img_sics_gif, data_img_sics_gif + 14, sizeof(data_img_sics_gif) - 14}};
const struct fsdata_file file_404_html[] = {{file_img_sics_gif, data_404_html, data_404_html + 10, sizeof(data_404_html) - 10}};
const struct fsdata_file file_index_html[] = {{file_404_html, data_index_html, data_index_html + 12, sizeof(data_index_html) - 12}};
#define FS_ROOT file_index_html
#define FS_NUMFILES 3

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
* 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.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
#ifndef __FSDATA_H__
#define __FSDATA_H__
struct fsdata_file {
const struct fsdata_file *next;
const unsigned char *name;
const unsigned char *data;
const int len;
};
struct fsdata_file_noconst {
struct fsdata_file *next;
unsigned char *name;
unsigned char *data;
int len;
};
#endif /* __FSDATA_H__ */

244
apps/httpserver_raw/httpd.c Normal file
View File

@ -0,0 +1,244 @@
/*
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
* 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.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
#include "lwip/debug.h"
#include "lwip/stats.h"
#include "httpd.h"
#include "lwip/tcp.h"
#include "fs.h"
struct http_state {
char *file;
u16_t left;
u8_t retries;
};
/*-----------------------------------------------------------------------------------*/
static void
conn_err(void *arg, err_t err)
{
struct http_state *hs;
hs = arg;
mem_free(hs);
}
/*-----------------------------------------------------------------------------------*/
static void
close_conn(struct tcp_pcb *pcb, struct http_state *hs)
{
tcp_arg(pcb, NULL);
tcp_sent(pcb, NULL);
tcp_recv(pcb, NULL);
mem_free(hs);
tcp_close(pcb);
}
/*-----------------------------------------------------------------------------------*/
static void
send_data(struct tcp_pcb *pcb, struct http_state *hs)
{
err_t err;
u16_t len;
/* We cannot send more data than space available in the send
buffer. */
if (tcp_sndbuf(pcb) < hs->left) {
len = tcp_sndbuf(pcb);
} else {
len = hs->left;
}
do {
err = tcp_write(pcb, hs->file, len, 0);
if (err == ERR_MEM) {
len /= 2;
}
} while (err == ERR_MEM && len > 1);
if (err == ERR_OK) {
hs->file += len;
hs->left -= len;
/* } else {
printf("send_data: error %s len %d %d\n", lwip_strerr(err), len, tcp_sndbuf(pcb));*/
}
}
/*-----------------------------------------------------------------------------------*/
static err_t
http_poll(void *arg, struct tcp_pcb *pcb)
{
struct http_state *hs;
hs = arg;
/* printf("Polll\n");*/
if (hs == NULL) {
/* printf("Null, close\n");*/
tcp_abort(pcb);
return ERR_ABRT;
} else {
++hs->retries;
if (hs->retries == 4) {
tcp_abort(pcb);
return ERR_ABRT;
}
send_data(pcb, hs);
}
return ERR_OK;
}
/*-----------------------------------------------------------------------------------*/
static err_t
http_sent(void *arg, struct tcp_pcb *pcb, u16_t len)
{
struct http_state *hs;
hs = arg;
hs->retries = 0;
if (hs->left > 0) {
send_data(pcb, hs);
} else {
close_conn(pcb, hs);
}
return ERR_OK;
}
/*-----------------------------------------------------------------------------------*/
static err_t
http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
{
int i;
char *data;
struct fs_file file;
struct http_state *hs;
hs = arg;
if (err == ERR_OK && p != NULL) {
/* Inform TCP that we have taken the data. */
tcp_recved(pcb, p->tot_len);
if (hs->file == NULL) {
data = p->payload;
if (strncmp(data, "GET ", 4) == 0) {
for(i = 0; i < 40; i++) {
if (((char *)data + 4)[i] == ' ' ||
((char *)data + 4)[i] == '\r' ||
((char *)data + 4)[i] == '\n') {
((char *)data + 4)[i] = 0;
}
}
if (*(char *)(data + 4) == '/' &&
*(char *)(data + 5) == 0) {
fs_open("/index.html", &file);
} else if (!fs_open((char *)data + 4, &file)) {
fs_open("/404.html", &file);
}
hs->file = file.data;
hs->left = file.len;
/* printf("data %p len %ld\n", hs->file, hs->left);*/
pbuf_free(p);
send_data(pcb, hs);
/* Tell TCP that we wish be to informed of data that has been
successfully sent by a call to the http_sent() function. */
tcp_sent(pcb, http_sent);
} else {
pbuf_free(p);
close_conn(pcb, hs);
}
} else {
pbuf_free(p);
}
}
if (err == ERR_OK && p == NULL) {
close_conn(pcb, hs);
}
return ERR_OK;
}
/*-----------------------------------------------------------------------------------*/
static err_t
http_accept(void *arg, struct tcp_pcb *pcb, err_t err)
{
struct http_state *hs;
tcp_setprio(pcb, TCP_PRIO_MIN);
/* Allocate memory for the structure that holds the state of the
connection. */
hs = mem_malloc(sizeof(struct http_state));
if (hs == NULL) {
printf("http_accept: Out of memory\n");
return ERR_MEM;
}
/* Initialize the structure. */
hs->file = NULL;
hs->left = 0;
hs->retries = 0;
/* Tell TCP that this is the structure we wish to be passed for our
callbacks. */
tcp_arg(pcb, hs);
/* Tell TCP that we wish to be informed of incoming data by a call
to the http_recv() function. */
tcp_recv(pcb, http_recv);
tcp_err(pcb, conn_err);
tcp_poll(pcb, http_poll, 4);
return ERR_OK;
}
/*-----------------------------------------------------------------------------------*/
void
httpd_init(void)
{
struct tcp_pcb *pcb;
pcb = tcp_new();
tcp_bind(pcb, IP_ADDR_ANY, 80);
pcb = tcp_listen(pcb);
tcp_accept(pcb, http_accept);
}
/*-----------------------------------------------------------------------------------*/

View File

@ -0,0 +1,37 @@
/*
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
* 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.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
#ifndef __HTTPD_H__
#define __HTTPD_H__
void httpd_init(void);
#endif /* __HTTPD_H__ */

43
apps/netio/netio.c Normal file
View File

@ -0,0 +1,43 @@
#include "netio.h"
#include "lwip/opt.h"
#include "lwip/tcp.h"
#if LWIP_TCP
static err_t netio_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
{
if (err == ERR_OK && p != NULL) {
tcp_recved(pcb, p->tot_len);
pbuf_free(p);
} else {
pbuf_free(p);
}
if (err == ERR_OK && p == NULL) {
tcp_arg(pcb, NULL);
tcp_sent(pcb, NULL);
tcp_recv(pcb, NULL);
tcp_close(pcb);
}
return ERR_OK;
}
static err_t netio_accept(void *arg, struct tcp_pcb *pcb, err_t err)
{
tcp_arg(pcb, NULL);
tcp_sent(pcb, NULL);
tcp_recv(pcb, netio_recv);
return ERR_OK;
}
void netio_init(void)
{
struct tcp_pcb *pcb;
pcb = tcp_new();
tcp_bind(pcb, IP_ADDR_ANY, 18767);
pcb = tcp_listen(pcb);
tcp_accept(pcb, netio_accept);
}
#endif /* LWIP_TCP */

6
apps/netio/netio.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef __NETIO_H__
#define __NETIO_H__
void netio_init(void);
#endif /* __NETIO_H__ */

View File

@ -204,6 +204,8 @@ a lot of data that needs to be copied, this should be set high. */
turning this on does currently not work. */
#define LWIP_DHCP 0
#define LWIP_AUTOIP 0
/* 1 if you want to do an ARP check on the offered address
(recommended). */
#if LWIP_DHCP

View File

@ -79,6 +79,9 @@
#include "netif/etharp.h"
/* include the port-dependent configuration */
#include "lwipcfg_msvc.h"
#undef NETIF_DEBUG
#define NETIF_DEBUG 0

View File

@ -42,6 +42,29 @@
#include <lwip/debug.h>
#include <lwip/sys.h>
/* These functions are used from NO_SYS also, for precise timer triggering */
LARGE_INTEGER freq, sys_start_time;
void sys_init_timing()
{
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&sys_start_time);
}
static LONGLONG sys_get_ms_longlong()
{
LONGLONG ret;
LARGE_INTEGER now;
QueryPerformanceCounter(&now);
ret = now.QuadPart-sys_start_time.QuadPart;
return (u32_t)(((ret)*1000)/freq.QuadPart);
}
u32_t sys_get_ms()
{
return sys_get_ms_longlong();
}
#if !NO_SYS
#define MAX_QUEUE_ENTRIES 100
@ -59,7 +82,6 @@ struct lwip_mbox {
};
struct threadlist *lwip_win32_threads = NULL;
LARGE_INTEGER freq, sys_start_time;
CRITICAL_SECTION critSec;
void InitSysArchProtect()
@ -83,20 +105,10 @@ void do_sleep(int ms)
void sys_init(void)
{
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&sys_start_time);
sys_init_timing();
InitSysArchProtect();
}
static LONGLONG sys_get_ms()
{
LONGLONG ret;
LARGE_INTEGER now;
QueryPerformanceCounter(&now);
ret = now.QuadPart-sys_start_time.QuadPart;
return (u32_t)(((ret)*1000)/freq.QuadPart);
}
sys_sem_t sys_sem_new(u8_t count)
{
HANDLE new_sem = NULL;
@ -142,22 +154,22 @@ u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout)
if(!timeout)
{
// wait infinite
starttime = sys_get_ms();
starttime = sys_get_ms_longlong();
ret = WaitForSingleObject(sem, INFINITE);
LWIP_ASSERT("Error waiting for mutex", ret == WAIT_OBJECT_0);
endtime = sys_get_ms();
endtime = sys_get_ms_longlong();
// return the time we waited for the sem
return (u32_t)(endtime - starttime);
}
else
{
int ret;
starttime = sys_get_ms();
starttime = sys_get_ms_longlong();
ret = WaitForSingleObject(sem, timeout);
LWIP_ASSERT("Error waiting for mutex", (ret == WAIT_OBJECT_0) || (ret == WAIT_TIMEOUT));
if(ret == WAIT_OBJECT_0)
{
endtime = sys_get_ms();
endtime = sys_get_ms_longlong();
// return the time we waited for the sem
return (u32_t)(endtime - starttime);
}
@ -330,7 +342,7 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t q, void **msg, u32_t timeout)
if (timeout == 0) {
timeout = INFINITE;
}
starttime = sys_get_ms();
starttime = sys_get_ms_longlong();
if ((ret = WaitForSingleObject(q->sem, timeout)) == WAIT_OBJECT_0) {
SYS_ARCH_PROTECT(lev);
if(msg != NULL) {
@ -342,7 +354,7 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t q, void **msg, u32_t timeout)
q->tail = 0;
}
SYS_ARCH_UNPROTECT(lev);
endtime = sys_get_ms();
endtime = sys_get_ms_longlong();
return (u32_t)(endtime - starttime);
}
else

View File

@ -49,51 +49,96 @@
#include "netif/loopif.h"
#include "httpd.h"
#include "httpserver_raw/httpd.h"
#include "netio/netio.h"
#if NO_SYS
/* ... then we need information about the timer intervals: */
#include "netif/etharp.h"
#include "lwip/ip_frag.h"
#include "lwip/igmp.h"
#include "lwip/dhcp.h"
#include "lwip/autoip.h"
#endif
/* include the port-dependent configuration */
#include "lwipcfg_msvc.h"
/* some forward function definitions... */
err_t ethernetif_init(struct netif *netif);
void shutdown_adapter(void);
void update_adapter(void);
#if NO_SYS
/* functions used for timer execution */
void sys_init_timing();
u32_t sys_get_ms();
#endif
#if LWIP_TCP
static err_t netio_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
/* THE ethernet interface */
struct netif netif;
#if LWIP_HAVE_LOOPIF
/* THE loopback interface */
struct netif loop_netif;
#endif /* LWIP_HAVE_LOOPIF */
/* my own input filtering function if using NO_SYS:
* this is 'stolen' from tcpip.c and might be used from there... */
#if LWIP_ARP
err_t
my_ethernet_input(struct pbuf *p, struct netif *netif)
{
if (err == ERR_OK && p != NULL) {
tcp_recved(pcb, p->tot_len);
pbuf_free(p);
} else {
pbuf_free(p);
struct eth_hdr* ethhdr;
/* points to packet payload, which starts with an Ethernet header */
ethhdr = p->payload;
switch (htons(ethhdr->type)) {
/* IP packet? */
case ETHTYPE_IP:
#if ETHARP_TRUST_IP_MAC
/* update ARP table */
etharp_ip_input( netif, p);
#endif /* ETHARP_TRUST_IP_MAC */
/* skip Ethernet header */
if(pbuf_header(p, -(s16_t)sizeof(struct eth_hdr))) {
LWIP_ASSERT("Can't move over header in packet", 0);
pbuf_free(p);
p = NULL;
} else {
/* pass to IP layer */
ip_input(p, netif);
}
break;
case ETHTYPE_ARP:
/* pass p to ARP module */
etharp_arp_input(netif, (struct eth_addr*)(netif->hwaddr), p);
break;
#if PPPOE_SUPPORT
case ETHTYPE_PPPOEDISC: /* PPP Over Ethernet Discovery Stage */
pppoe_disc_input(netif, p);
break;
case ETHTYPE_PPPOE: /* PPP Over Ethernet Session Stage */
pppoe_data_input(netif, p);
break;
#endif /* PPPOE_SUPPORT */
default:
pbuf_free(p);
p = NULL;
break;
}
if (err == ERR_OK && p == NULL) {
tcp_arg(pcb, NULL);
tcp_sent(pcb, NULL);
tcp_recv(pcb, NULL);
tcp_close(pcb);
}
return ERR_OK;
return ERR_OK; /* return value ignored */
}
#endif /* LWIP_ARP */
static err_t netio_accept(void *arg, struct tcp_pcb *pcb, err_t err)
{
tcp_arg(pcb, NULL);
tcp_sent(pcb, NULL);
tcp_recv(pcb, netio_recv);
return ERR_OK;
}
void netio_init(void)
{
struct tcp_pcb *pcb;
pcb = tcp_new();
tcp_bind(pcb, IP_ADDR_ANY, 18767);
pcb = tcp_listen(pcb);
tcp_accept(pcb, netio_accept);
}
#endif /* LWIP_TCP */
/* a sipmle multicast test */
#if LWIP_UDP && LWIP_IGMP
void mcast_init(void)
{
@ -128,9 +173,7 @@ void mcast_init(void)
#define mcast_init()
#endif /* LWIP_UDP && LWIP_IGMP*/
struct netif netif;
struct netif loop_netif;
/* This function initializes all network interfaces */
void my_netif_init()
{
struct ip_addr ipaddr, netmask, gw;
@ -138,13 +181,17 @@ void my_netif_init()
struct ip_addr loop_ipaddr, loop_netmask, loop_gw;
#endif /* LWIP_HAVE_LOOPIF */
IP4_ADDR(&gw, 192,168,1,1);
IP4_ADDR(&ipaddr, 192,168,1,200);
IP4_ADDR(&netmask, 255,255,255,0);
LWIP_PORT_INIT_GW(&gw);
LWIP_PORT_INIT_IPADDR(&ipaddr);
LWIP_PORT_INIT_NETMASK(&netmask);
printf("Starting lwIP, local interface IP is %s\n", inet_ntoa(*(struct in_addr*)&ipaddr));
#if NO_SYS
#if LWIP_ARP
netif_set_default(netif_add(&netif, &ipaddr, &netmask, &gw, NULL, ethernetif_init, my_ethernet_input));
#else /* LWIP_ARP */
netif_set_default(netif_add(&netif, &ipaddr, &netmask, &gw, NULL, ethernetif_init, ip_input));
#endif /* LWIP_ARP */
#else /* NO_SYS */
netif_set_default(netif_add(&netif, &ipaddr, &netmask, &gw, NULL, ethernetif_init, tcpip_input));
#endif /* NO_SYS */
@ -165,21 +212,27 @@ void my_netif_init()
#endif /* LWIP_HAVE_LOOPIF */
}
/* This is somewhat different to other ports: we have a main loop here:
* a dedicated task that waits for packets to arrive. This would normally be
* done from interrupt context with embedded hardware, but we don't get an
* interrupt in windows for that :-) */
void main_loop()
{
#if NO_SYS
int last_time;
int timer1;
int timer2;
int timerTcpFast, timerTcpSlow, timerArp;
int timerDhcpFine, timerDhcpCoarse, timerIpReass;
int timerAutoIP, timerIgmp;
#endif /* NO_SYS */
int done;
#if NO_SYS
lwip_init();
sys_init_timing();
#else /* NO_SYS */
tcpip_init(0,0);
my_netif_init();
#endif /* NO_SYS */
my_netif_init();
#if LWIP_UDP
mcast_init();
@ -192,45 +245,105 @@ void main_loop()
#if NO_SYS
last_time=clock();
timer1=0;
timer2=0;
last_time = clock();
timerTcpFast = 0;
timerTcpSlow = 0;
timerArp = 0;
timerDhcpFine = 0;
timerDhcpCoarse = 0;
timerIpReass = 0;
timerAutoIP = 0;
timerIgmp = 0;
#endif /* NO_SYS */
done=0;
done = 0;
while (!done) {
#if NO_SYS
int cur_time;
int time_diff;
cur_time=clock();
time_diff=cur_time-last_time;
if (time_diff>0) {
last_time=cur_time;
timer1+=time_diff;
timer2+=time_diff;
cur_time = sys_get_ms();
time_diff = cur_time - last_time;
/* the '> 0' is an easy wrap-around check: the big gap at
* the wraparound step is simply ignored... */
if (time_diff > 0) {
last_time = cur_time;
timerTcpFast += time_diff;
timerTcpSlow += time_diff;
timerArp += time_diff;
timerDhcpFine += time_diff;
timerDhcpCoarse += time_diff;
timerIpReass += time_diff;
timerAutoIP += time_diff;
timerIgmp += time_diff;
}
if (timer1>10) {
#if LWIP_TCP
/* execute TCP fast timer every 250 ms */
if (timerTcpFast > TCP_TMR_INTERVAL) {
tcp_fasttmr();
timer1=0;
timerTcpFast = 0;
}
if (timer2>45) {
/* execute TCP slow timer every 500 ms */
if (timerTcpSlow > ((TCP_TMR_INTERVAL)*2)) {
tcp_slowtmr();
timer2=0;
done=_kbhit();
timerTcpSlow = 0;
done = _kbhit();
}
#endif /* LWIP_TCP */
#if LWIP_ARP
/* execute ARP timer */
if (timerArp > ARP_TMR_INTERVAL) {
etharp_tmr();
timerArp = 0;
}
#endif /* LWIP_ARP */
#if LWIP_DHCP
/* execute DHCP fine timer */
if (timerDhcpFine > DHCP_FINE_TIMER_MSECS) {
dhcp_fine_tmr();
timerDhcpFine = 0;
}
/* execute DHCP coarse timer */
if (timerDhcpCoarse > DHCP_COARSE_TIMER_SECS*1000) {
dhcp_coarse_tmr();
timerDhcpCoarse = 0;
}
#endif /* LWIP_DHCP */
#if IP_REASSEMBLY
/* execute IP reassembly timer */
if (timerIpReass > IP_TMR_INTERVAL) {
ip_reass_tmr();
timerIpReass = 0;
}
#endif /* IP_REASSEMBLY*/
#if LWIP_AUTOIP
/* execute AUTOIP timer */
if (timerAutoIP > AUTOIP_TMR_INTERVAL) {
autoip_tmr();
timerAutoIP = 0;
}
#endif /* LWIP_AUTOIP */
#if LWIP_IGMP
/* execute IGP timer */
if (timerIgmp > IGMP_TMR_INTERVAL) {
igmp_tmr();
timerIgmp = 0;
}
#endif /* LWIP_IGMP */
/* TODO: execute other timers... */
#endif /* NO_SYS */
/* check for packets */
update_adapter();
}
/* release the pcap library... */
shutdown_adapter();
}
int main(void)
{
/* no stdio-buffering, please! */
setvbuf(stdout, NULL,_IONBF, 0);
main_loop();