Commit 42b850f2 authored by Dean Camera's avatar Dean Camera
Browse files

Use a temporary variable to hold the current URI length in the Webserver,...

Use a temporary variable to hold the current URI length in the Webserver, rather than calling strlen() multiple times on an unchanged buffer. Clean up uip-split.c.
parent 012628f6
...@@ -168,7 +168,7 @@ static void HTTPServerApp_OpenRequestedFile(void) ...@@ -168,7 +168,7 @@ static void HTTPServerApp_OpenRequestedFile(void)
if (!(uip_newdata())) if (!(uip_newdata()))
return; return;
char* RequestToken = strtok(AppData, " "); char* RequestToken = strtok(AppData, " ");
char* RequestedFileName = strtok(NULL, " "); char* RequestedFileName = strtok(NULL, " ");
/* Must be a GET request, abort otherwise */ /* Must be a GET request, abort otherwise */
...@@ -182,16 +182,19 @@ static void HTTPServerApp_OpenRequestedFile(void) ...@@ -182,16 +182,19 @@ static void HTTPServerApp_OpenRequestedFile(void)
strncpy(AppState->HTTPServer.FileName, &RequestedFileName[1], (sizeof(AppState->HTTPServer.FileName) - 1)); strncpy(AppState->HTTPServer.FileName, &RequestedFileName[1], (sizeof(AppState->HTTPServer.FileName) - 1));
/* Ensure filename is null-terminated */ /* Ensure filename is null-terminated */
AppState->HTTPServer.FileName[(sizeof(AppState->HTTPServer.FileName) - 1)] = 0x00; AppState->HTTPServer.FileName[sizeof(AppState->HTTPServer.FileName) - 1] = 0x00;
/* Determine the length of the URI so that it can be checked to see if it is a directory */
uint8_t FileNameLen = strlen(AppState->HTTPServer.FileName);
/* If the URI is a directory, append the default filename */ /* If the URI is a directory, append the default filename */
if (AppState->HTTPServer.FileName[strlen(AppState->HTTPServer.FileName) - 1] == '/') if (AppState->HTTPServer.FileName[FileNameLen - 1] == '/')
{ {
strncpy_P(&AppState->HTTPServer.FileName[strlen(AppState->HTTPServer.FileName)], DefaultDirFileName, strncpy_P(&AppState->HTTPServer.FileName[FileNameLen], DefaultDirFileName,
(sizeof(AppState->HTTPServer.FileName) - (strlen(AppState->HTTPServer.FileName) + 1))); (sizeof(AppState->HTTPServer.FileName) - FileNameLen));
/* Ensure altered filename is still null-terminated */ /* Ensure altered filename is still null-terminated */
AppState->HTTPServer.FileName[(sizeof(AppState->HTTPServer.FileName) - 1)] = 0x00; AppState->HTTPServer.FileName[sizeof(AppState->HTTPServer.FileName) - 1] = 0x00;
} }
/* Try to open the file from the Dataflash disk */ /* Try to open the file from the Dataflash disk */
...@@ -233,7 +236,7 @@ static void HTTPServerApp_SendResponseHeader(void) ...@@ -233,7 +236,7 @@ static void HTTPServerApp_SendResponseHeader(void)
if (Extension != NULL) if (Extension != NULL)
{ {
/* Look through the MIME type list, copy over the required MIME type if found */ /* Look through the MIME type list, copy over the required MIME type if found */
for (int i = 0; i < (sizeof(MIMETypes) / sizeof(MIMETypes[0])); i++) for (uint8_t i = 0; i < (sizeof(MIMETypes) / sizeof(MIMETypes[0])); i++)
{ {
if (strcmp(&Extension[1], MIMETypes[i].Extension) == 0) if (strcmp(&Extension[1], MIMETypes[i].Extension) == 0)
{ {
...@@ -251,7 +254,7 @@ static void HTTPServerApp_SendResponseHeader(void) ...@@ -251,7 +254,7 @@ static void HTTPServerApp_SendResponseHeader(void)
strcpy_P(&AppData[strlen(AppData)], DefaultMIMEType); strcpy_P(&AppData[strlen(AppData)], DefaultMIMEType);
} }
/* Add the end-of line terminator and end-of-headers terminator after the MIME type */ /* Add the end-of-line terminator and end-of-headers terminator after the MIME type */
strcpy(&AppData[strlen(AppData)], "\r\n\r\n"); strcpy(&AppData[strlen(AppData)], "\r\n\r\n");
/* Send the MIME header to the receiving client */ /* Send the MIME header to the receiving client */
......
...@@ -52,7 +52,7 @@ void uIPManagement_Init(void) ...@@ -52,7 +52,7 @@ void uIPManagement_Init(void)
{ {
/* uIP Timing Initialization */ /* uIP Timing Initialization */
clock_init(); clock_init();
timer_set(&ConnectionTimer, CLOCK_SECOND / 5); timer_set(&ConnectionTimer, CLOCK_SECOND / 2);
timer_set(&ARPTimer, CLOCK_SECOND * 10); timer_set(&ARPTimer, CLOCK_SECOND * 10);
/* uIP Stack Initialization */ /* uIP Stack Initialization */
......
...@@ -80,7 +80,6 @@ uip_split_output(void) ...@@ -80,7 +80,6 @@ uip_split_output(void)
#endif /* UIP_CONF_IPV6 */ #endif /* UIP_CONF_IPV6 */
/* Transmit the first packet. */ /* Transmit the first packet. */
/* uip_fw_output();*/
#if UIP_CONF_IPV6 #if UIP_CONF_IPV6
tcpip_ipv6_output(); tcpip_ipv6_output();
#else #else
...@@ -103,7 +102,6 @@ uip_split_output(void) ...@@ -103,7 +102,6 @@ uip_split_output(void)
BUF->len[1] = (uip_len - UIP_LLH_LEN) & 0xff; BUF->len[1] = (uip_len - UIP_LLH_LEN) & 0xff;
#endif /* UIP_CONF_IPV6 */ #endif /* UIP_CONF_IPV6 */
/* uip_appdata += len1;*/
memcpy(uip_appdata, (u8_t *)uip_appdata + len1, len2); memcpy(uip_appdata, (u8_t *)uip_appdata + len1, len2);
uip_add32(BUF->seqno, len1); uip_add32(BUF->seqno, len1);
...@@ -123,12 +121,10 @@ uip_split_output(void) ...@@ -123,12 +121,10 @@ uip_split_output(void)
#endif /* UIP_CONF_IPV6 */ #endif /* UIP_CONF_IPV6 */
/* Transmit the second packet. */ /* Transmit the second packet. */
/* uip_fw_output();*/
#if UIP_CONF_IPV6 #if UIP_CONF_IPV6
tcpip_ipv6_output(); tcpip_ipv6_output();
#else #else
RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, uip_buf, uip_len); RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, uip_buf, uip_len);
//tcpip_output();
#endif /* UIP_CONF_IPV6 */ #endif /* UIP_CONF_IPV6 */
return; return;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment