aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/Webserver/Lib/WebserverApp.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-01-27 13:15:49 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-01-27 13:15:49 +0000
commita960e4b3b2ae72c6c3573fb690a1b9cde1642bc0 (patch)
tree97eeeedafe3c60ce692f6eec00e9427866a4b8d1 /Projects/Webserver/Lib/WebserverApp.c
parent1aeb5056d6943331ee2d11807bcc0a6480ad1ca0 (diff)
downloadlufa-a960e4b3b2ae72c6c3573fb690a1b9cde1642bc0.tar.gz
lufa-a960e4b3b2ae72c6c3573fb690a1b9cde1642bc0.tar.bz2
lufa-a960e4b3b2ae72c6c3573fb690a1b9cde1642bc0.zip
Add DHCP server to the Webserver demo for automatic network configuration. Correct uIP timer clock not tracking the correct timespan.
Diffstat (limited to 'Projects/Webserver/Lib/WebserverApp.c')
-rw-r--r--Projects/Webserver/Lib/WebserverApp.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/Projects/Webserver/Lib/WebserverApp.c b/Projects/Webserver/Lib/WebserverApp.c
index cba3b43fa..02f38be87 100644
--- a/Projects/Webserver/Lib/WebserverApp.c
+++ b/Projects/Webserver/Lib/WebserverApp.c
@@ -76,7 +76,7 @@ char PROGMEM HTTPPage[] =
void WebserverApp_Init(void)
{
/* Listen on port 80 for HTTP connections from hosts */
- uip_listen(HTONS(80));
+ uip_listen(HTONS(HTTP_SERVER_PORT));
}
/** uIP stack application callback for the simple HTTP webserver. This function must be called each time the
@@ -84,8 +84,9 @@ void WebserverApp_Init(void)
*/
void WebserverApp_Callback(void)
{
- char* AppDataPtr = (char*)uip_appdata;
- uint16_t AppDataSize = 0;
+ uip_tcp_appstate_t* const AppState = &uip_conn->appstate;
+ char* AppData = (char*)uip_appdata;
+ uint16_t AppDataSize = 0;
if (uip_closed() || uip_aborted() || uip_timedout())
{
@@ -95,12 +96,12 @@ void WebserverApp_Callback(void)
else if (uip_connected())
{
/* New connection - initialize connection state and data pointer to the appropriate HTTP header */
- uip_conn->appstate.SendPos = HTTP200Header;
- uip_conn->appstate.CurrentState = WEBSERVER_STATE_SendHeaders;
+ AppState->SendPos = HTTP200Header;
+ AppState->CurrentState = WEBSERVER_STATE_SendHeaders;
}
/* Calculate the maximum segment size and remaining data size */
- uint16_t BytesRemaining = strlen_P(uip_conn->appstate.SendPos);
+ uint16_t BytesRemaining = strlen_P(AppState->SendPos);
uint16_t MaxSegSize = uip_mss();
/* No more bytes remaining in the current data being sent - progress to next data chunk or
@@ -108,15 +109,15 @@ void WebserverApp_Callback(void)
if (!(BytesRemaining))
{
/* Check which data chunk we are currently sending (header or data) */
- if (uip_conn->appstate.CurrentState == WEBSERVER_STATE_SendHeaders)
+ if (AppState->CurrentState == WEBSERVER_STATE_SendHeaders)
{
- uip_conn->appstate.SendPos = HTTPPage;
- uip_conn->appstate.CurrentState = WEBSERVER_STATE_SendData;
+ AppState->SendPos = HTTPPage;
+ AppState->CurrentState = WEBSERVER_STATE_SendData;
}
- else if (uip_conn->appstate.CurrentState == WEBSERVER_STATE_SendData)
+ else if (AppState->CurrentState == WEBSERVER_STATE_SendData)
{
uip_close();
- uip_conn->appstate.CurrentState = WEBSERVER_STATE_Closed;
+ AppState->CurrentState = WEBSERVER_STATE_Closed;
}
return;
@@ -133,9 +134,9 @@ void WebserverApp_Callback(void)
}
/* Copy over the next data segment to the application buffer, advance send position pointer */
- strncpy_P(uip_appdata, uip_conn->appstate.SendPos, AppDataSize);
- uip_conn->appstate.SendPos += AppDataSize;
+ strncpy_P(AppData, AppState->SendPos, AppDataSize);
+ AppState->SendPos += AppDataSize;
/* Send the data to the requesting host */
- uip_send(AppDataPtr, AppDataSize);
+ uip_send(AppData, AppDataSize);
}