X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/7d3ed400704f76e4ea3bae759d1c2298b1098585..a7aaa45ec4c3f415bf6073a5cc016635d5ecf77d:/Projects/Webserver/Lib/uIPManagement.c?ds=inline diff --git a/Projects/Webserver/Lib/uIPManagement.c b/Projects/Webserver/Lib/uIPManagement.c index 37080dfd7..bd7804e6e 100644 --- a/Projects/Webserver/Lib/uIPManagement.c +++ b/Projects/Webserver/Lib/uIPManagement.c @@ -30,7 +30,7 @@ /** \file * - * uIP Managament functions. This file contains the functions and globals needed to maintain the uIP + * uIP Management functions. This file contains the functions and globals needed to maintain the uIP * stack once an RNDIS device has been attached to the system. */ @@ -52,7 +52,7 @@ void uIPManagement_Init(void) { /* uIP Timing Initialization */ clock_init(); - timer_set(&ConnectionTimer, CLOCK_SECOND / 10); + timer_set(&ConnectionTimer, CLOCK_SECOND / 2); timer_set(&ARPTimer, CLOCK_SECOND * 10); /* uIP Stack Initialization */ @@ -61,7 +61,7 @@ void uIPManagement_Init(void) uip_setethaddr(MACAddress); /* DHCP/Server IP Settings Initialization */ - #if defined(ENABLE_DHCP) + #if defined(ENABLE_DHCP_CLIENT) DHCPClientApp_Init(); #else uip_ipaddr_t IPAddress, Netmask, GatewayIPAddress; @@ -87,7 +87,7 @@ void uIPManagement_ManageNetwork(void) { if ((USB_CurrentMode == USB_MODE_HOST) && (USB_HostState == HOST_STATE_Configured)) { - uIPManagement_ProcessIncommingPacket(); + uIPManagement_ProcessIncomingPacket(); uIPManagement_ManageConnections(); } } @@ -123,8 +123,8 @@ void uIPManagement_UDPCallback(void) } } -/** Processes incomming packets to the server from the connected RNDIS device, creating responses as needed. */ -static void uIPManagement_ProcessIncommingPacket(void) +/** Processes Incoming packets to the server from the connected RNDIS device, creating responses as needed. */ +static void uIPManagement_ProcessIncomingPacket(void) { /* If no packet received, exit processing routine */ if (!(RNDIS_Host_IsPacketReceived(&Ethernet_RNDIS_Interface))) @@ -132,7 +132,7 @@ static void uIPManagement_ProcessIncommingPacket(void) LEDs_SetAllLEDs(LEDMASK_USB_BUSY); - /* Read the incomming packet straight into the UIP packet buffer */ + /* Read the Incoming packet straight into the UIP packet buffer */ RNDIS_Host_ReadPacket(&Ethernet_RNDIS_Interface, uip_buf, &uip_len); /* If the packet contains an Ethernet frame, process it */ @@ -144,7 +144,7 @@ static void uIPManagement_ProcessIncommingPacket(void) /* Filter packet by MAC destination */ uip_arp_ipin(); - /* Process incomming packet */ + /* Process Incoming packet */ uip_input(); /* If a response was generated, send it */ @@ -153,7 +153,7 @@ static void uIPManagement_ProcessIncommingPacket(void) /* Add destination MAC to outgoing packet */ uip_arp_out(); - RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, uip_buf, uip_len); + uip_split_output(); } break; @@ -163,7 +163,7 @@ static void uIPManagement_ProcessIncommingPacket(void) /* If a response was generated, send it */ if (uip_len > 0) - RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, uip_buf, uip_len); + uip_split_output(); break; } @@ -175,6 +175,22 @@ static void uIPManagement_ProcessIncommingPacket(void) /** Manages the currently open network connections, including TCP and (if enabled) UDP. */ static void uIPManagement_ManageConnections(void) { + /* 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(); + + /* Split and send the outgoing packet */ + uip_split_output(); + } + } + /* Manage open connections for timeouts */ if (timer_expired(&ConnectionTimer)) { @@ -193,11 +209,12 @@ static void uIPManagement_ManageConnections(void) /* Add destination MAC to outgoing packet */ uip_arp_out(); - RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, uip_buf, uip_len); + /* Split and send the outgoing packet */ + uip_split_output(); } } - #if defined(ENABLE_DHCP) + #if defined(ENABLE_DHCP_CLIENT) for (uint8_t i = 0; i < UIP_UDP_CONNS; i++) { /* Run periodic connection management for each UDP connection */ @@ -209,7 +226,8 @@ static void uIPManagement_ManageConnections(void) /* Add destination MAC to outgoing packet */ uip_arp_out(); - RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, uip_buf, uip_len); + /* Split and send the outgoing packet */ + uip_split_output(); } } #endif