update project file.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@8 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
5488777d55
commit
7b2813b739
|
@ -1,11 +1,11 @@
|
|||
/*
|
||||
* File : app.c
|
||||
* File : application.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://openlab.rt-thread.com/license/LICENSE
|
||||
* http://www.rt-thread.org/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
|
@ -36,213 +36,6 @@
|
|||
#include <lwip/api.h>
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_RTGUI
|
||||
#include <rtgui/rtgui.h>
|
||||
#endif
|
||||
|
||||
#include "lwip/sockets.h"
|
||||
#define MAX_SERV 5 /* Maximum number of chargen services. Don't need too many */
|
||||
#define CHARGEN_THREAD_NAME "chargen"
|
||||
#define CHARGEN_PRIORITY 200 /* Really low priority */
|
||||
#define CHARGEN_THREAD_STACKSIZE 1024
|
||||
struct charcb
|
||||
{
|
||||
struct charcb *next;
|
||||
int socket;
|
||||
struct sockaddr_in cliaddr;
|
||||
socklen_t clilen;
|
||||
char nextchar;
|
||||
};
|
||||
|
||||
static struct charcb *charcb_list = 0;
|
||||
static int do_read(struct charcb *p_charcb);
|
||||
static void close_chargen(struct charcb *p_charcb);
|
||||
|
||||
/**************************************************************
|
||||
* void chargen_thread(void *arg)
|
||||
*
|
||||
* chargen task. This server will wait for connections on well
|
||||
* known TCP port number: 19. For every connection, the server will
|
||||
* write as much data as possible to the tcp port.
|
||||
**************************************************************/
|
||||
static void chargen_thread(void *arg)
|
||||
{
|
||||
int listenfd;
|
||||
struct sockaddr_in chargen_saddr;
|
||||
fd_set readset;
|
||||
fd_set writeset;
|
||||
int i, maxfdp1;
|
||||
struct charcb *p_charcb;
|
||||
|
||||
/* First acquire our socket for listening for connections */
|
||||
listenfd = lwip_socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
|
||||
LWIP_ASSERT("chargen_thread(): Socket create failed.", listenfd >= 0);
|
||||
memset(&chargen_saddr, 0, sizeof(chargen_saddr));
|
||||
chargen_saddr.sin_family = AF_INET;
|
||||
chargen_saddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
chargen_saddr.sin_port = htons(19); // Chargen server port
|
||||
|
||||
if (lwip_bind(listenfd, (struct sockaddr *) &chargen_saddr, sizeof(chargen_saddr)) == -1)
|
||||
LWIP_ASSERT("chargen_thread(): Socket bind failed.", 0);
|
||||
|
||||
/* Put socket into listening mode */
|
||||
if (lwip_listen(listenfd, MAX_SERV) == -1)
|
||||
LWIP_ASSERT("chargen_thread(): Listen failed.", 0);
|
||||
|
||||
/* Wait forever for network input: This could be connections or data */
|
||||
for (;;)
|
||||
{
|
||||
maxfdp1 = listenfd+1;
|
||||
|
||||
/* Determine what sockets need to be in readset */
|
||||
FD_ZERO(&readset);
|
||||
FD_ZERO(&writeset);
|
||||
FD_SET(listenfd, &readset);
|
||||
for (p_charcb = charcb_list; p_charcb; p_charcb = p_charcb->next)
|
||||
{
|
||||
if (maxfdp1 < p_charcb->socket + 1)
|
||||
maxfdp1 = p_charcb->socket + 1;
|
||||
FD_SET(p_charcb->socket, &readset);
|
||||
FD_SET(p_charcb->socket, &writeset);
|
||||
}
|
||||
|
||||
/* Wait for data or a new connection */
|
||||
i = lwip_select(maxfdp1, &readset, &writeset, 0, 0);
|
||||
|
||||
if (i == 0) continue;
|
||||
|
||||
/* At least one descriptor is ready */
|
||||
if (FD_ISSET(listenfd, &readset))
|
||||
{
|
||||
/* We have a new connection request!!! */
|
||||
/* Lets create a new control block */
|
||||
p_charcb = (struct charcb *)rt_calloc(1, sizeof(struct charcb));
|
||||
if (p_charcb)
|
||||
{
|
||||
p_charcb->socket = lwip_accept(listenfd,
|
||||
(struct sockaddr *) &p_charcb->cliaddr,
|
||||
&p_charcb->clilen);
|
||||
if (p_charcb->socket < 0)
|
||||
rt_free(p_charcb);
|
||||
else
|
||||
{
|
||||
/* Keep this tecb in our list */
|
||||
p_charcb->next = charcb_list;
|
||||
charcb_list = p_charcb;
|
||||
p_charcb->nextchar = 0x21;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No memory to accept connection. Just accept and then close */
|
||||
int sock;
|
||||
struct sockaddr cliaddr;
|
||||
socklen_t clilen;
|
||||
|
||||
sock = lwip_accept(listenfd, &cliaddr, &clilen);
|
||||
if (sock >= 0)
|
||||
lwip_close(sock);
|
||||
}
|
||||
}
|
||||
/* Go through list of connected clients and process data */
|
||||
for (p_charcb = charcb_list; p_charcb; p_charcb = p_charcb->next)
|
||||
{
|
||||
if (FD_ISSET(p_charcb->socket, &readset))
|
||||
{
|
||||
/* This socket is ready for reading. This could be because someone typed
|
||||
* some characters or it could be because the socket is now closed. Try reading
|
||||
* some data to see. */
|
||||
if (do_read(p_charcb) < 0)
|
||||
break;
|
||||
}
|
||||
if (FD_ISSET(p_charcb->socket, &writeset))
|
||||
{
|
||||
char line[80];
|
||||
char setchar = p_charcb->nextchar;
|
||||
|
||||
for( i = 0; i < 59; i++)
|
||||
{
|
||||
line[i] = setchar;
|
||||
if (++setchar == 0x7f)
|
||||
setchar = 0x21;
|
||||
}
|
||||
line[i] = 0;
|
||||
strcat(line, "\n\r");
|
||||
if (lwip_write(p_charcb->socket, line, strlen(line)) < 0)
|
||||
{
|
||||
close_chargen(p_charcb);
|
||||
break;
|
||||
}
|
||||
if (++p_charcb->nextchar == 0x7f)
|
||||
p_charcb->nextchar = 0x21;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
* void close_chargen(struct charcb *p_charcb)
|
||||
*
|
||||
* Close the socket and remove this charcb from the list.
|
||||
**************************************************************/
|
||||
static void close_chargen(struct charcb *p_charcb)
|
||||
{
|
||||
struct charcb *p_search_charcb;
|
||||
|
||||
/* Either an error or tcp connection closed on other
|
||||
* end. Close here */
|
||||
lwip_close(p_charcb->socket);
|
||||
|
||||
/* Free charcb */
|
||||
if (charcb_list == p_charcb)
|
||||
charcb_list = p_charcb->next;
|
||||
else
|
||||
for (p_search_charcb = charcb_list; p_search_charcb; p_search_charcb = p_search_charcb->next)
|
||||
{
|
||||
if (p_search_charcb->next == p_charcb)
|
||||
{
|
||||
p_search_charcb->next = p_charcb->next;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
rt_free(p_charcb);
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
* void do_read(struct charcb *p_charcb)
|
||||
*
|
||||
* Socket definitely is ready for reading. Read a buffer from the socket and
|
||||
* discard the data. If no data is read, then the socket is closed and the
|
||||
* charcb is removed from the list and freed.
|
||||
**************************************************************/
|
||||
static int do_read(struct charcb *p_charcb)
|
||||
{
|
||||
char buffer[80];
|
||||
int readcount;
|
||||
|
||||
/* Read some data */
|
||||
readcount = lwip_read(p_charcb->socket, &buffer, 80);
|
||||
if (readcount <= 0)
|
||||
{
|
||||
close_chargen(p_charcb);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void chargen_init(void)
|
||||
{
|
||||
rt_thread_t chargen;
|
||||
|
||||
chargen = rt_thread_create(CHARGEN_THREAD_NAME,
|
||||
chargen_thread, RT_NULL,
|
||||
CHARGEN_THREAD_STACKSIZE,
|
||||
CHARGEN_PRIORITY, 5);
|
||||
if (chargen != RT_NULL) rt_thread_startup(chargen);
|
||||
}
|
||||
|
||||
/* thread phase init */
|
||||
void rt_init_thread_entry(void *parameter)
|
||||
{
|
||||
|
@ -270,20 +63,6 @@ void rt_init_thread_entry(void *parameter)
|
|||
/* init lwip system */
|
||||
lwip_sys_init();
|
||||
rt_kprintf("TCP/IP initialized!\n");
|
||||
|
||||
#ifdef RT_USING_WEBSERVER
|
||||
{
|
||||
extern void thread_webserver(void *parameter);
|
||||
rt_thread_t webserver;
|
||||
|
||||
webserver = rt_thread_create("twebsrv",
|
||||
thread_webserver, RT_NULL,
|
||||
4096, 140, 20);
|
||||
rt_thread_startup(webserver);
|
||||
|
||||
chargen_init();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -18,9 +18,8 @@ GRPOPT 4,(STM32),0,0,0
|
|||
GRPOPT 5,(finsh),0,0,0
|
||||
GRPOPT 6,(Filesystem),0,0,0
|
||||
GRPOPT 7,(LwIP),0,0,0
|
||||
GRPOPT 8,(GoAhead),0,0,0
|
||||
|
||||
OPTFFF 1,1,1,0,0,0,0,0,<.\application.c><application.c>
|
||||
OPTFFF 1,1,1,1,0,0,0,0,<.\application.c><application.c>
|
||||
OPTFFF 1,2,1,0,0,0,0,0,<.\board.c><board.c>
|
||||
OPTFFF 1,3,1,0,0,0,0,0,<.\startup.c><startup.c>
|
||||
OPTFFF 1,4,2,0,0,0,0,0,<.\cortexm3_macro.s><cortexm3_macro.s>
|
||||
|
@ -142,33 +141,6 @@ OPTFFF 7,119,1,0,0,0,0,0,<..\..\net\lwip\src\arch\sys_arch_init.c><sys_arch_init
|
|||
OPTFFF 7,120,1,0,0,0,0,0,<..\..\net\lwip\src\arch\sys_arch.c><sys_arch.c>
|
||||
OPTFFF 7,121,1,0,0,0,0,0,<..\..\net\lwip\src\api\sockets.c><sockets.c>
|
||||
OPTFFF 7,122,1,0,0,0,0,0,<..\..\net\lwip\src\core\memp_tiny.c><memp_tiny.c>
|
||||
OPTFFF 8,123,1,0,0,0,0,0,<..\..\net\webserver\websuemf.c><websuemf.c>
|
||||
OPTFFF 8,124,1,0,0,0,0,0,<..\..\net\webserver\asp.c><asp.c>
|
||||
OPTFFF 8,125,1,0,0,0,0,0,<..\..\net\webserver\balloc.c><balloc.c>
|
||||
OPTFFF 8,126,1,0,0,0,0,0,<..\..\net\webserver\base64.c><base64.c>
|
||||
OPTFFF 8,127,1,0,0,0,0,0,<..\..\net\webserver\default.c><default.c>
|
||||
OPTFFF 8,128,1,0,0,0,0,0,<..\..\net\webserver\ejlex.c><ejlex.c>
|
||||
OPTFFF 8,129,1,0,0,0,0,0,<..\..\net\webserver\ejparse.c><ejparse.c>
|
||||
OPTFFF 8,130,1,0,0,0,0,0,<..\..\net\webserver\emfdb.c><emfdb.c>
|
||||
OPTFFF 8,131,1,0,0,0,0,0,<..\..\net\webserver\form.c><form.c>
|
||||
OPTFFF 8,132,1,0,0,0,0,0,<..\..\net\webserver\h.c><h.c>
|
||||
OPTFFF 8,133,1,0,0,0,0,0,<..\..\net\webserver\handler.c><handler.c>
|
||||
OPTFFF 8,134,1,0,0,0,0,0,<..\..\net\webserver\mime.c><mime.c>
|
||||
OPTFFF 8,135,1,0,0,0,0,0,<..\..\net\webserver\misc.c><misc.c>
|
||||
OPTFFF 8,136,1,0,0,0,0,0,<..\..\net\webserver\page.c><page.c>
|
||||
OPTFFF 8,137,1,0,0,0,0,0,<..\..\net\webserver\ringq.c><ringq.c>
|
||||
OPTFFF 8,138,1,0,0,0,0,0,<..\..\net\webserver\rom.c><rom.c>
|
||||
OPTFFF 8,139,1,0,0,0,0,0,<..\..\net\webserver\security.c><security.c>
|
||||
OPTFFF 8,140,1,0,0,0,0,0,<..\..\net\webserver\sock.c><sock.c>
|
||||
OPTFFF 8,141,1,0,0,0,0,0,<..\..\net\webserver\sockGen.c><sockGen.c>
|
||||
OPTFFF 8,142,1,0,0,0,0,0,<..\..\net\webserver\sym.c><sym.c>
|
||||
OPTFFF 8,143,1,0,0,0,0,0,<..\..\net\webserver\uemf.c><uemf.c>
|
||||
OPTFFF 8,144,1,33554432,0,0,0,0,<..\..\net\webserver\um.c><um.c>
|
||||
OPTFFF 8,145,1,0,0,0,0,0,<..\..\net\webserver\umui.c><umui.c>
|
||||
OPTFFF 8,146,1,0,0,0,0,0,<..\..\net\webserver\url.c><url.c>
|
||||
OPTFFF 8,147,1,0,0,0,0,0,<..\..\net\webserver\value.c><value.c>
|
||||
OPTFFF 8,148,1,0,0,0,0,0,<..\..\net\webserver\webs.c><webs.c>
|
||||
OPTFFF 8,149,1,0,0,0,0,0,<..\..\net\webserver\RTT\main.c><main.c>
|
||||
|
||||
|
||||
TARGOPT 1, (RT-Thread/STM32)
|
||||
|
|
|
@ -10,7 +10,6 @@ Group (STM32)
|
|||
Group (finsh)
|
||||
Group (Filesystem)
|
||||
Group (LwIP)
|
||||
Group (GoAhead)
|
||||
|
||||
File 1,1,<.\application.c><application.c>
|
||||
File 1,1,<.\board.c><board.c>
|
||||
|
@ -134,33 +133,6 @@ File 7,1,<..\..\net\lwip\src\arch\sys_arch_init.c><sys_arch_init.c>
|
|||
File 7,1,<..\..\net\lwip\src\arch\sys_arch.c><sys_arch.c>
|
||||
File 7,1,<..\..\net\lwip\src\api\sockets.c><sockets.c>
|
||||
File 7,1,<..\..\net\lwip\src\core\memp_tiny.c><memp_tiny.c>
|
||||
File 8,1,<..\..\net\webserver\websuemf.c><websuemf.c>
|
||||
File 8,1,<..\..\net\webserver\asp.c><asp.c>
|
||||
File 8,1,<..\..\net\webserver\balloc.c><balloc.c>
|
||||
File 8,1,<..\..\net\webserver\base64.c><base64.c>
|
||||
File 8,1,<..\..\net\webserver\default.c><default.c>
|
||||
File 8,1,<..\..\net\webserver\ejlex.c><ejlex.c>
|
||||
File 8,1,<..\..\net\webserver\ejparse.c><ejparse.c>
|
||||
File 8,1,<..\..\net\webserver\emfdb.c><emfdb.c>
|
||||
File 8,1,<..\..\net\webserver\form.c><form.c>
|
||||
File 8,1,<..\..\net\webserver\h.c><h.c>
|
||||
File 8,1,<..\..\net\webserver\handler.c><handler.c>
|
||||
File 8,1,<..\..\net\webserver\mime.c><mime.c>
|
||||
File 8,1,<..\..\net\webserver\misc.c><misc.c>
|
||||
File 8,1,<..\..\net\webserver\page.c><page.c>
|
||||
File 8,1,<..\..\net\webserver\ringq.c><ringq.c>
|
||||
File 8,1,<..\..\net\webserver\rom.c><rom.c>
|
||||
File 8,1,<..\..\net\webserver\security.c><security.c>
|
||||
File 8,1,<..\..\net\webserver\sock.c><sock.c>
|
||||
File 8,1,<..\..\net\webserver\sockGen.c><sockGen.c>
|
||||
File 8,1,<..\..\net\webserver\sym.c><sym.c>
|
||||
File 8,1,<..\..\net\webserver\uemf.c><uemf.c>
|
||||
File 8,1,<..\..\net\webserver\um.c><um.c>
|
||||
File 8,1,<..\..\net\webserver\umui.c><umui.c>
|
||||
File 8,1,<..\..\net\webserver\url.c><url.c>
|
||||
File 8,1,<..\..\net\webserver\value.c><value.c>
|
||||
File 8,1,<..\..\net\webserver\webs.c><webs.c>
|
||||
File 8,1,<..\..\net\webserver\RTT\main.c><main.c>
|
||||
|
||||
|
||||
Options 1,0,0 // Target 'RT-Thread/STM32'
|
||||
|
@ -253,25 +225,3 @@ Options 1,0,0 // Target 'RT-Thread/STM32'
|
|||
FLASH4 ()
|
||||
EndOpt
|
||||
|
||||
Options 1,8,0 // Group 'GoAhead'
|
||||
PropFld { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
|
||||
IncBld=2
|
||||
AlwaysBuild=2
|
||||
GenAsm=2
|
||||
AsmAsm=2
|
||||
PublicsOnly=2
|
||||
StopCode=11
|
||||
CustArgs ()
|
||||
LibMods ()
|
||||
ADSCCFLG { 2,84,85,33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
|
||||
ADSCMISC ()
|
||||
ADSCDEFN (WEBS, UEMF, RTT, __NO_FCNTL=1,USER_MANAGEMENT_SUPPORT)
|
||||
ADSCUDEF ()
|
||||
ADSCINCD (..\..\net\webserver)
|
||||
ADSASFLG { 170,42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
|
||||
ADSAMISC ()
|
||||
ADSADEFN ()
|
||||
ADSAUDEF ()
|
||||
ADSAINCD ()
|
||||
EndOpt
|
||||
|
||||
|
|
|
@ -96,7 +96,6 @@
|
|||
/* SECTION: lwip, a lighwight TCP/IP protocol stack */
|
||||
/* Using lighweight TCP/IP protocol stack*/
|
||||
#define RT_USING_LWIP
|
||||
#define RT_USING_WEBSERVER
|
||||
|
||||
/* Trace LwIP protocol*/
|
||||
/* #define RT_LWIP_DEBUG */
|
||||
|
|
Loading…
Reference in New Issue