aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/Incomplete/Webserver/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Projects/Incomplete/Webserver/Lib')
-rw-r--r--Projects/Incomplete/Webserver/Lib/WebserverApp.c15
-rw-r--r--Projects/Incomplete/Webserver/Lib/WebserverApp.h3
-rw-r--r--Projects/Incomplete/Webserver/Lib/uip/conf/apps-conf.h2
3 files changed, 16 insertions, 4 deletions
diff --git a/Projects/Incomplete/Webserver/Lib/WebserverApp.c b/Projects/Incomplete/Webserver/Lib/WebserverApp.c
index 11acec4b7..6ac94d6ac 100644
--- a/Projects/Incomplete/Webserver/Lib/WebserverApp.c
+++ b/Projects/Incomplete/Webserver/Lib/WebserverApp.c
@@ -51,7 +51,6 @@ char PROGMEM HTTP404Header[] = "HTTP/1.1 404 Not Found\r\n"
"Server: LUFA RNDIS\r\n"
"Connection: close\r\n\r\n";
-/****************************************************************************************/
/** HTTP page to serve to the host when a HTTP request is made. This page is too long for a single response, thus it is automatically
* broken up into smaller blocks and sent as a series of packets each time the webserver application callback is run.
*/
@@ -75,7 +74,17 @@ char PROGMEM HTTPPage[] =
" </body>"
"</html>";
-void WebserverAppCallback(void)
+/** Initialization function for the simple HTTP webserver. */
+void WebserverApp_Init(void)
+{
+ /* Listen on port 80 for HTTP connections from hosts */
+ uip_listen(HTONS(80));
+}
+
+/** uIP stack application callback for the simple HTTP webserver. This function must be called each time the
+ * TCP/IP stack needs a TCP packet to be processed.
+ */
+void WebserverApp_Callback(void)
{
char* AppDataPtr = (char*)uip_appdata;
uint16_t AppDataSize = 0;
@@ -116,10 +125,12 @@ void WebserverAppCallback(void)
}
else if (BytesRemaining > MaxSegSize)
{
+ /* More bytes remaining to send than the maximum segment size, send next chunk */
AppDataSize = MaxSegSize;
}
else
{
+ /* Less bytes than the segment size remaining, send all remaining bytes in the one packet */
AppDataSize = BytesRemaining;
}
diff --git a/Projects/Incomplete/Webserver/Lib/WebserverApp.h b/Projects/Incomplete/Webserver/Lib/WebserverApp.h
index b2696b28f..4d1d76cc9 100644
--- a/Projects/Incomplete/Webserver/Lib/WebserverApp.h
+++ b/Projects/Incomplete/Webserver/Lib/WebserverApp.h
@@ -45,6 +45,7 @@
#include <uip.h>
/* Function Prototypes: */
- void WebserverAppCallback(void);
+ void WebserverApp_Init(void);
+ void WebserverApp_Callback(void);
#endif
diff --git a/Projects/Incomplete/Webserver/Lib/uip/conf/apps-conf.h b/Projects/Incomplete/Webserver/Lib/uip/conf/apps-conf.h
index 00919f221..22bab81bf 100644
--- a/Projects/Incomplete/Webserver/Lib/uip/conf/apps-conf.h
+++ b/Projects/Incomplete/Webserver/Lib/uip/conf/apps-conf.h
@@ -14,7 +14,7 @@
char* SendPos;
} uip_tcp_appstate_t;
- #define UIP_APPCALL WebserverAppCallback
+ #define UIP_APPCALL WebserverApp_Callback
void UIP_APPCALL(void);
#endif /*__APPS_CONF_H__*/