if (uip_aborted() || uip_timedout() || uip_closed())\r
{\r
/* Connection is being terminated for some reason - close file handle */\r
- f_close(&AppState->FileHandle);\r
- AppState->FileOpen = false;\r
+ f_close(&AppState->HTTPServer.FileHandle);\r
+ AppState->HTTPServer.FileOpen = false;\r
\r
/* Lock to the closed state so that no further processing will occur on the connection */\r
- AppState->CurrentState = WEBSERVER_STATE_Closed;\r
- AppState->NextState = WEBSERVER_STATE_Closed;\r
+ AppState->HTTPServer.CurrentState = WEBSERVER_STATE_Closed;\r
+ AppState->HTTPServer.NextState = WEBSERVER_STATE_Closed;\r
}\r
\r
if (uip_connected())\r
{\r
/* New connection - initialize connection state values */\r
- AppState->CurrentState = WEBSERVER_STATE_OpenRequestedFile;\r
- AppState->NextState = WEBSERVER_STATE_OpenRequestedFile;\r
- AppState->FileOpen = false;\r
- AppState->ACKedFilePos = 0;\r
- AppState->SentChunkSize = 0;\r
+ AppState->HTTPServer.CurrentState = WEBSERVER_STATE_OpenRequestedFile;\r
+ AppState->HTTPServer.NextState = WEBSERVER_STATE_OpenRequestedFile;\r
+ AppState->HTTPServer.FileOpen = false;\r
+ AppState->HTTPServer.ACKedFilePos = 0;\r
+ AppState->HTTPServer.SentChunkSize = 0;\r
}\r
\r
if (uip_acked())\r
{\r
/* Add the amount of ACKed file data to the total sent file bytes counter */\r
- AppState->ACKedFilePos += AppState->SentChunkSize;\r
+ AppState->HTTPServer.ACKedFilePos += AppState->HTTPServer.SentChunkSize;\r
\r
/* Progress to the next state once the current state's data has been ACKed */\r
- AppState->CurrentState = AppState->NextState;\r
+ AppState->HTTPServer.CurrentState = AppState->HTTPServer.NextState;\r
}\r
\r
if (uip_rexmit() || uip_acked() || uip_newdata() || uip_connected() || uip_poll())\r
{\r
- switch (AppState->CurrentState)\r
+ switch (AppState->HTTPServer.CurrentState)\r
{\r
case WEBSERVER_STATE_OpenRequestedFile:\r
HTTPServerApp_OpenRequestedFile();\r
case WEBSERVER_STATE_Closing:\r
uip_close();\r
\r
- AppState->NextState = WEBSERVER_STATE_Closed;\r
+ AppState->HTTPServer.NextState = WEBSERVER_STATE_Closed;\r
break;\r
} \r
} \r
\r
/* If the requested filename has more that just the leading '/' path in it, copy it over */\r
if (strlen(RequestedFileName) > 1)\r
- strncpy(AppState->FileName, &RequestedFileName[1], (sizeof(AppState->FileName) - 1));\r
+ strncpy(AppState->HTTPServer.FileName, &RequestedFileName[1], (sizeof(AppState->HTTPServer.FileName) - 1));\r
else\r
- strcpy(AppState->FileName, "index.htm");\r
+ strcpy(AppState->HTTPServer.FileName, "index.htm");\r
\r
/* Ensure filename is null-terminated */\r
- AppState->FileName[(sizeof(AppState->FileName) - 1)] = 0x00;\r
+ AppState->HTTPServer.FileName[(sizeof(AppState->HTTPServer.FileName) - 1)] = 0x00;\r
\r
/* Try to open the file from the Dataflash disk */\r
- AppState->FileOpen = (f_open(&AppState->FileHandle, AppState->FileName, FA_OPEN_EXISTING | FA_READ) == FR_OK);\r
+ AppState->HTTPServer.FileOpen = (f_open(&AppState->HTTPServer.FileHandle, AppState->HTTPServer.FileName, FA_OPEN_EXISTING | FA_READ) == FR_OK);\r
\r
/* Lock to the SendResponseHeader state until connection terminated */\r
- AppState->CurrentState = WEBSERVER_STATE_SendResponseHeader;\r
- AppState->NextState = WEBSERVER_STATE_SendResponseHeader;\r
+ AppState->HTTPServer.CurrentState = WEBSERVER_STATE_SendResponseHeader;\r
+ AppState->HTTPServer.NextState = WEBSERVER_STATE_SendResponseHeader;\r
}\r
\r
/** HTTP Server State handler for the HTTP Response Header Send state. This state manages the transmission of\r
uint16_t HeaderLength;\r
\r
/* Determine which HTTP header should be sent to the client */\r
- if (AppState->FileOpen)\r
+ if (AppState->HTTPServer.FileOpen)\r
{\r
HeaderToSend = HTTP200Header;\r
- AppState->NextState = WEBSERVER_STATE_SendMIMETypeHeader;\r
+ AppState->HTTPServer.NextState = WEBSERVER_STATE_SendMIMETypeHeader;\r
}\r
else\r
{\r
HeaderToSend = HTTP404Header;\r
- AppState->NextState = WEBSERVER_STATE_Closing;\r
+ AppState->HTTPServer.NextState = WEBSERVER_STATE_Closing;\r
}\r
\r
/* Copy over the HTTP response header and send it to the receiving client */\r
uip_tcp_appstate_t* const AppState = &uip_conn->appstate;\r
char* const AppData = (char*)uip_appdata;\r
\r
- char* Extension = strpbrk(AppState->FileName, ".");\r
+ char* Extension = strpbrk(AppState->HTTPServer.FileName, ".");\r
uint16_t MIMEHeaderLength = 0;\r
\r
/* Check to see if a file extension was found for the requested filename */\r
uip_send(AppData, MIMEHeaderLength);\r
\r
/* When the MIME header is ACKed, progress to the data send stage */\r
- AppState->NextState = WEBSERVER_STATE_SendData;\r
+ AppState->HTTPServer.NextState = WEBSERVER_STATE_SendData;\r
}\r
\r
/** HTTP Server State handler for the Data Send state. This state manages the transmission of file chunks\r
uint16_t MaxSegmentSize = uip_mss();\r
\r
/* Return file pointer to the last ACKed position */\r
- f_lseek(&AppState->FileHandle, AppState->ACKedFilePos);\r
+ f_lseek(&AppState->HTTPServer.FileHandle, AppState->HTTPServer.ACKedFilePos);\r
\r
/* Read the next chunk of data from the open file */\r
- f_read(&AppState->FileHandle, AppData, MaxSegmentSize, &AppState->SentChunkSize);\r
+ f_read(&AppState->HTTPServer.FileHandle, AppData, MaxSegmentSize, &AppState->HTTPServer.SentChunkSize);\r
\r
/* Send the next file chunk to the receiving client */\r
- uip_send(AppData, AppState->SentChunkSize);\r
+ uip_send(AppData, AppState->HTTPServer.SentChunkSize);\r
\r
/* Check if we are at the last chunk of the file, if so next ACK should close the connection */\r
- AppState->NextState = (MaxSegmentSize != AppState->SentChunkSize) ? WEBSERVER_STATE_Closing : WEBSERVER_STATE_SendData;\r
+ AppState->HTTPServer.NextState = (MaxSegmentSize != AppState->HTTPServer.SentChunkSize) ? WEBSERVER_STATE_Closing : WEBSERVER_STATE_SendData;\r
}\r