aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/Webserver/Lib/uIPManagement.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-01-31 04:23:55 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-01-31 04:23:55 +0000
commit97f7cd947be1469c223d09b2e6573051f6629cee (patch)
tree9afd9e15a799d6dc5a31dcc1e1e4bfa769f74607 /Projects/Webserver/Lib/uIPManagement.c
parente8b8ed2bad293b190c6b2ce9a575e73fbf93e9e2 (diff)
downloadlufa-97f7cd947be1469c223d09b2e6573051f6629cee.tar.gz
lufa-97f7cd947be1469c223d09b2e6573051f6629cee.tar.bz2
lufa-97f7cd947be1469c223d09b2e6573051f6629cee.zip
Better HTTP GET parsing in the Webserver demo, add application polling.
Diffstat (limited to 'Projects/Webserver/Lib/uIPManagement.c')
-rw-r--r--Projects/Webserver/Lib/uIPManagement.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/Projects/Webserver/Lib/uIPManagement.c b/Projects/Webserver/Lib/uIPManagement.c
index f00119372..c816dea6c 100644
--- a/Projects/Webserver/Lib/uIPManagement.c
+++ b/Projects/Webserver/Lib/uIPManagement.c
@@ -52,7 +52,7 @@ void uIPManagement_Init(void)
{
/* uIP Timing Initialization */
clock_init();
- timer_set(&ConnectionTimer, CLOCK_SECOND / 100);
+ timer_set(&ConnectionTimer, CLOCK_SECOND / 2);
timer_set(&ARPTimer, CLOCK_SECOND * 10);
/* uIP Stack Initialization */
@@ -97,13 +97,13 @@ static void uIPManagement_ProcessIncommingPacket(void)
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
/* Read the incomming packet straight into the UIP packet buffer */
- RNDIS_Host_ReadPacket(&Ethernet_RNDIS_Interface, &uip_buf[0], &uip_len);
+ RNDIS_Host_ReadPacket(&Ethernet_RNDIS_Interface, uip_buf, &uip_len);
if (uip_len > 0)
{
bool PacketHandled = true;
- struct uip_eth_hdr* EthernetHeader = (struct uip_eth_hdr*)&uip_buf[0];
+ struct uip_eth_hdr* EthernetHeader = (struct uip_eth_hdr*)uip_buf;
if (EthernetHeader->type == HTONS(UIP_ETHTYPE_IP))
{
/* Filter packet by MAC destination */
@@ -128,7 +128,7 @@ static void uIPManagement_ProcessIncommingPacket(void)
/* If a response was generated, send it */
if ((uip_len > 0) && PacketHandled)
- RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, &uip_buf[0], uip_len);
+ RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, uip_buf, uip_len);
}
LEDs_SetAllLEDs(LEDMASK_USB_READY);
@@ -138,7 +138,22 @@ static void uIPManagement_ProcessIncommingPacket(void)
/** Manages the currently open network connections, including TCP and (if enabled) UDP. */
static void uIPManagement_ManageConnections(void)
{
- /* Manage open connections */
+ /* Poll TCP connections for more data to send back to the host */
+ for (uint8_t i = 0; i < UIP_CONNS; i++)
+ {
+ uip_poll_conn(&uip_conns[i]);
+
+ /* If a response was generated, send it */
+ if (uip_len > 0)
+ {
+ /* Add destination MAC to outgoing packet */
+ uip_arp_out();
+
+ RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, uip_buf, uip_len);
+ }
+ }
+
+ /* Manage open connections for timeouts */
if (timer_expired(&ConnectionTimer))
{
timer_reset(&ConnectionTimer);
@@ -156,7 +171,7 @@ static void uIPManagement_ManageConnections(void)
/* Add destination MAC to outgoing packet */
uip_arp_out();
- RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, &uip_buf[0], uip_len);
+ RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, uip_buf, uip_len);
}
}
@@ -172,7 +187,7 @@ static void uIPManagement_ManageConnections(void)
/* Add destination MAC to outgoing packet */
uip_arp_out();
- RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, &uip_buf[0], uip_len);
+ RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, uip_buf, uip_len);
}
}
#endif