"
- "µIP Web Server
"
- "This web page is served by a small web server running on top of "
- "the µIP embedded TCP/IP "
- "stack."
- "
"
- "The µIP stack is running on a "
- "Texas Instruments "
- "Stellaris® Ethernet Evaluation Kit"
- "
"
- "This page has been sent ";
+ "
"
+ "µIP Web Server
"
+ "This web page is served by a small web server running on top of "
+ "the µIP embedded TCP/IP "
+ "stack."
+ "
"
+ "The µIP stack is running on a "
+ "Texas Instruments "
+ "Stellaris® Ethernet Evaluation Kit"
+ "
"
+ "This page has been sent ";
static char default_page_buf2of3[] =
- "00001";
+ "00001";
static const char default_page_buf3of3[] =
- " times since reset!"
- "
"
+ " times since reset!"
+ ""
""
-"";
+ "";
//*****************************************************************************
//
@@ -125,51 +125,51 @@ static const char default_page_buf3of3[] =
static void
httpd_inc_page_count(void)
{
- //
- // Increment the 'ones' digit. If it wraps, then increment the 'tens'
- // digit.
- //
- default_page_buf2of3[4]++;
- if(default_page_buf2of3[4] == 0x3a)
- {
- default_page_buf2of3[4] = 0x30;
- default_page_buf2of3[3]++;
- }
+ //
+ // Increment the 'ones' digit. If it wraps, then increment the 'tens'
+ // digit.
+ //
+ default_page_buf2of3[4]++;
+ if (default_page_buf2of3[4] == 0x3a)
+ {
+ default_page_buf2of3[4] = 0x30;
+ default_page_buf2of3[3]++;
+ }
- //
- // If the 'tens' digit wraps, increment the 'hundreds' digit.
- //
- if(default_page_buf2of3[3] == 0x3a)
- {
- default_page_buf2of3[3] = 0x30;
- default_page_buf2of3[2]++;
- }
+ //
+ // If the 'tens' digit wraps, increment the 'hundreds' digit.
+ //
+ if (default_page_buf2of3[3] == 0x3a)
+ {
+ default_page_buf2of3[3] = 0x30;
+ default_page_buf2of3[2]++;
+ }
- //
- // If the 'hundreds' digit wraps, increment the 'thousands' digit.
- //
- if(default_page_buf2of3[2] == 0x3a)
- {
- default_page_buf2of3[2] = 0x30;
- default_page_buf2of3[1]++;
- }
+ //
+ // If the 'hundreds' digit wraps, increment the 'thousands' digit.
+ //
+ if (default_page_buf2of3[2] == 0x3a)
+ {
+ default_page_buf2of3[2] = 0x30;
+ default_page_buf2of3[1]++;
+ }
- //
- // If the 'thousands' digit wraps, increment the 'ten-thousands' digit.
- //
- if(default_page_buf2of3[1] == 0x3a)
- {
- default_page_buf2of3[1] = 0x30;
- default_page_buf2of3[0]++;
- }
+ //
+ // If the 'thousands' digit wraps, increment the 'ten-thousands' digit.
+ //
+ if (default_page_buf2of3[1] == 0x3a)
+ {
+ default_page_buf2of3[1] = 0x30;
+ default_page_buf2of3[0]++;
+ }
- //
- // If the 'ten-thousands' digit wrapped, start over.
- //
- if(default_page_buf2of3[0] == 0x3a)
- {
- default_page_buf2of3[0] = 0x30;
- }
+ //
+ // If the 'ten-thousands' digit wrapped, start over.
+ //
+ if (default_page_buf2of3[0] == 0x3a)
+ {
+ default_page_buf2of3[0] = 0x30;
+ }
}
//*****************************************************************************
@@ -182,10 +182,10 @@ httpd_inc_page_count(void)
void
httpd_init(void)
{
- //
- // Listen to port 80.
- //
- uip_listen(HTONS(80));
+ //
+ // Listen to port 80.
+ //
+ uip_listen(HTONS(80));
}
//*****************************************************************************
@@ -196,129 +196,129 @@ httpd_init(void)
void
httpd_appcall(void)
{
- switch(uip_conn->lport)
+ switch (uip_conn->lport)
+ {
+ //
+ // This is the web server:
+ //
+ case HTONS(80):
{
+ //
+ // Pick out the application state from the uip_conn structure.
+ //
+ hs = (struct httpd_state *)&(uip_conn->appstate);
+
+ //
+ // We use the uip_ test functions to deduce why we were
+ // called. If uip_connected() is non-zero, we were called
+ // because a remote host has connected to us. If
+ // uip_newdata() is non-zero, we were called because the
+ // remote host has sent us new data, and if uip_acked() is
+ // non-zero, the remote host has acknowledged the data we
+ // previously sent to it. */
+ if (uip_connected())
+ {
//
- // This is the web server:
+ // Since we have just been connected with the remote host, we
+ // reset the state for this connection. The ->count variable
+ // contains the amount of data that is yet to be sent to the
+ // remote host, and the ->state is set to HTTP_NOGET to signal
+ // that we haven't received any HTTP GET request for this
+ // connection yet.
//
- case HTONS(80):
+ hs->state = HTTP_NOGET;
+ hs->count = 0;
+ return;
+ }
+ else if (uip_poll())
+ {
+ //
+ // If we are polled ten times, we abort the connection. This is
+ // because we don't want connections lingering indefinately in
+ // the system.
+ //
+ if (hs->count++ >= 10)
{
- //
- // Pick out the application state from the uip_conn structure.
- //
- hs = (struct httpd_state *)&(uip_conn->appstate);
-
- //
- // We use the uip_ test functions to deduce why we were
- // called. If uip_connected() is non-zero, we were called
- // because a remote host has connected to us. If
- // uip_newdata() is non-zero, we were called because the
- // remote host has sent us new data, and if uip_acked() is
- // non-zero, the remote host has acknowledged the data we
- // previously sent to it. */
- if(uip_connected())
- {
- //
- // Since we have just been connected with the remote host, we
- // reset the state for this connection. The ->count variable
- // contains the amount of data that is yet to be sent to the
- // remote host, and the ->state is set to HTTP_NOGET to signal
- // that we haven't received any HTTP GET request for this
- // connection yet.
- //
- hs->state = HTTP_NOGET;
- hs->count = 0;
- return;
- }
- else if(uip_poll())
- {
- //
- // If we are polled ten times, we abort the connection. This is
- // because we don't want connections lingering indefinately in
- // the system.
- //
- if(hs->count++ >= 10)
- {
- uip_abort();
- }
- return;
- }
- else if(uip_newdata() && hs->state == HTTP_NOGET)
- {
- //
- // This is the first data we receive, and it should contain a
- // GET.
- //
- // Check for GET.
- //
- if(BUF_APPDATA[0] != 'G' ||
- BUF_APPDATA[1] != 'E' ||
- BUF_APPDATA[2] != 'T' ||
- BUF_APPDATA[3] != ' ')
- {
- //
- // If it isn't a GET, we abort the connection.
- //
- uip_abort();
- return;
- }
-
- //
- // Check to see what we should send.
- //
- if((BUF_APPDATA[4] == '/') &&
- (BUF_APPDATA[5] == ' '))
- {
- //
- // Send buffer 1
- //
- uip_send(default_page_buf1of3,
- sizeof(default_page_buf1of3) - 1);
- }
- else
- {
- uip_send(page_not_found,
- sizeof(page_not_found) - 1);
- hs->count = 3;
- }
- }
- else if(uip_acked())
- {
- hs->count++;
- if(hs->count == 1)
- {
- uip_send(default_page_buf2of3,
- sizeof(default_page_buf2of3) - 1);
- }
- else if(hs->count == 2)
- {
- uip_send(default_page_buf3of3,
- sizeof(default_page_buf3of3) - 1);
- }
- else if(hs->count == 3)
- {
- httpd_inc_page_count();
- uip_close();
- }
- else
- {
- uip_close();
- }
- }
- //
- // Finally, return to uIP. Our outgoing packet will soon be on its
- // way...
- //
- return;
+ uip_abort();
+ }
+ return;
+ }
+ else if (uip_newdata() && hs->state == HTTP_NOGET)
+ {
+ //
+ // This is the first data we receive, and it should contain a
+ // GET.
+ //
+ // Check for GET.
+ //
+ if (BUF_APPDATA[0] != 'G' ||
+ BUF_APPDATA[1] != 'E' ||
+ BUF_APPDATA[2] != 'T' ||
+ BUF_APPDATA[3] != ' ')
+ {
+ //
+ // If it isn't a GET, we abort the connection.
+ //
+ uip_abort();
+ return;
}
- default:
+ //
+ // Check to see what we should send.
+ //
+ if ((BUF_APPDATA[4] == '/') &&
+ (BUF_APPDATA[5] == ' '))
{
- //
- // Should never happen.
- //
- uip_abort();
- break;
+ //
+ // Send buffer 1
+ //
+ uip_send(default_page_buf1of3,
+ sizeof(default_page_buf1of3) - 1);
}
+ else
+ {
+ uip_send(page_not_found,
+ sizeof(page_not_found) - 1);
+ hs->count = 3;
+ }
+ }
+ else if (uip_acked())
+ {
+ hs->count++;
+ if (hs->count == 1)
+ {
+ uip_send(default_page_buf2of3,
+ sizeof(default_page_buf2of3) - 1);
+ }
+ else if (hs->count == 2)
+ {
+ uip_send(default_page_buf3of3,
+ sizeof(default_page_buf3of3) - 1);
+ }
+ else if (hs->count == 3)
+ {
+ httpd_inc_page_count();
+ uip_close();
+ }
+ else
+ {
+ uip_close();
+ }
+ }
+ //
+ // Finally, return to uIP. Our outgoing packet will soon be on its
+ // way...
+ //
+ return;
}
+
+ default:
+ {
+ //
+ // Should never happen.
+ //
+ uip_abort();
+ break;
+ }
+ }
}
diff --git a/Target/Source/third_party/uip/apps/httpd/httpd.h b/Target/Source/third_party/uip/apps/httpd/httpd.h
index 16d7e5d9..8d20b5e9 100644
--- a/Target/Source/third_party/uip/apps/httpd/httpd.h
+++ b/Target/Source/third_party/uip/apps/httpd/httpd.h
@@ -3,19 +3,19 @@
// Adam Dunkels