Exclude FATFs from the Webserver project documentation. Rename the functions in the...
[pub/USBasp.git] / Projects / Webserver / Lib / uIPManagement.c
index c816dea..e207d9c 100644 (file)
@@ -52,11 +52,12 @@ void uIPManagement_Init(void)
 {\r
        /* uIP Timing Initialization */\r
        clock_init();\r
-       timer_set(&ConnectionTimer, CLOCK_SECOND / 2);\r
+       timer_set(&ConnectionTimer, CLOCK_SECOND / 8);\r
        timer_set(&ARPTimer, CLOCK_SECOND * 10);        \r
 \r
        /* uIP Stack Initialization */\r
        uip_init();\r
+       uip_arp_init();\r
 \r
        /* DHCP/Server IP Settings Initialization */\r
        #if defined(ENABLE_DHCP)\r
@@ -74,7 +75,7 @@ void uIPManagement_Init(void)
        uip_setethaddr(MACAddress);\r
        \r
        /* HTTP Webserver Initialization */\r
-       WebserverApp_Init();\r
+       HTTPServerApp_Init();\r
 }\r
 \r
 /** uIP Management function. This function manages the uIP stack when called while an RNDIS device has been\r
@@ -92,47 +93,50 @@ void uIPManagement_ManageNetwork(void)
 /** Processes incomming packets to the server from the connected RNDIS device, creating responses as needed. */\r
 static void uIPManagement_ProcessIncommingPacket(void)\r
 {\r
-       if (RNDIS_Host_IsPacketReceived(&Ethernet_RNDIS_Interface))\r
-       {\r
-               LEDs_SetAllLEDs(LEDMASK_USB_BUSY);\r
+       /* If no packet received, exit processing routine */\r
+       if (!(RNDIS_Host_IsPacketReceived(&Ethernet_RNDIS_Interface)))\r
+         return;\r
+         \r
+       LEDs_SetAllLEDs(LEDMASK_USB_BUSY);\r
 \r
-               /* Read the incomming packet straight into the UIP packet buffer */\r
-               RNDIS_Host_ReadPacket(&Ethernet_RNDIS_Interface, uip_buf, &uip_len);\r
+       /* Read the incomming packet straight into the UIP packet buffer */\r
+       RNDIS_Host_ReadPacket(&Ethernet_RNDIS_Interface, uip_buf, &uip_len);\r
 \r
-               if (uip_len > 0)\r
+       /* If the packet contains an Ethernet frame, process it */\r
+       if (uip_len > 0)\r
+       {\r
+               switch (((struct uip_eth_hdr*)uip_buf)->type)\r
                {\r
-                       bool PacketHandled = true;\r
-\r
-                       struct uip_eth_hdr* EthernetHeader = (struct uip_eth_hdr*)uip_buf;\r
-                       if (EthernetHeader->type == HTONS(UIP_ETHTYPE_IP))\r
-                       {\r
+                       case HTONS(UIP_ETHTYPE_IP):\r
                                /* Filter packet by MAC destination */\r
                                uip_arp_ipin();\r
 \r
                                /* Process incomming packet */\r
                                uip_input();\r
 \r
-                               /* Add destination MAC to outgoing packet */\r
+                               /* If a response was generated, send it */\r
                                if (uip_len > 0)\r
-                                 uip_arp_out();\r
-                       }\r
-                       else if (EthernetHeader->type == HTONS(UIP_ETHTYPE_ARP))\r
-                       {\r
+                               {\r
+                                       /* Add destination MAC to outgoing packet */\r
+                                       uip_arp_out();\r
+\r
+                                       RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, uip_buf, uip_len);\r
+                               }\r
+                               \r
+                               break;\r
+                       case HTONS(UIP_ETHTYPE_ARP):\r
                                /* Process ARP packet */\r
                                uip_arp_arpin();\r
-                       }\r
-                       else\r
-                       {\r
-                               PacketHandled = false;\r
-                       }\r
-\r
-                       /* If a response was generated, send it */\r
-                       if ((uip_len > 0) && PacketHandled)\r
-                         RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, uip_buf, uip_len);\r
+                               \r
+                               /* If a response was generated, send it */\r
+                               if (uip_len > 0)\r
+                                 RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, uip_buf, uip_len);\r
+                               \r
+                               break;\r
                }\r
-\r
-               LEDs_SetAllLEDs(LEDMASK_USB_READY);\r
        }\r
+\r
+       LEDs_SetAllLEDs(LEDMASK_USB_READY);\r
 }\r
 \r
 /** Manages the currently open network connections, including TCP and (if enabled) UDP. */\r