Add skeleton LUFAConfig.h to the CodeTemplates directory.
[pub/USBasp.git] / Projects / Webserver / Lib / uIPManagement.c
index 1270e18..a99e8be 100644 (file)
@@ -1,21 +1,21 @@
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2010.
-              
+     Copyright (C) Dean Camera, 2011.
+
   dean [at] fourwalledcubicle [dot] com
-      www.fourwalledcubicle.com
+           www.lufa-lib.org
 */
 
 /*
-  Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 
-  Permission to use, copy, modify, distribute, and sell this 
+  Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
-  without fee, provided that the above copyright notice appear in 
+  without fee, provided that the above copyright notice appear in
   all copies and that both that the copyright notice and this
-  permission notice and warranty disclaimer appear in supporting 
-  documentation, and that the name of the author not be used in 
-  advertising or publicity pertaining to distribution of the 
+  permission notice and warranty disclaimer appear in supporting
+  documentation, and that the name of the author not be used in
+  advertising or publicity pertaining to distribution of the
   software without specific, written prior permission.
 
   The author disclaim all warranties with regard to this
 #include "uIPManagement.h"
 
 /** Connection timer, to retain the time elapsed since the last time the uIP connections were managed. */
-struct timer ConnectionTimer;
+static struct timer ConnectionTimer;
 
 /** ARP timer, to retain the time elapsed since the ARP cache was last updated. */
-struct timer ARPTimer;
+static struct timer ARPTimer;
 
-/** MAC address of the RNDIS device, when enumerated */
+/** MAC address of the RNDIS device, when enumerated. */
 struct uip_eth_addr MACAddress;
 
+/** Indicates if an IP configuration has been set in the device. */
 bool HaveIPConfiguration;
 
-/** Configures the uIP stack ready for network traffic. */
+
+/** Configures the uIP stack ready for network traffic processing. */
 void uIPManagement_Init(void)
 {
        /* uIP Timing Initialization */
        clock_init();
        timer_set(&ConnectionTimer, CLOCK_SECOND / 2);
-       timer_set(&ARPTimer, CLOCK_SECOND * 10);        
+       timer_set(&ARPTimer, CLOCK_SECOND * 10);
 
        /* uIP Stack Initialization */
        uip_init();
@@ -75,10 +77,10 @@ void uIPManagement_Init(void)
        uip_setnetmask(&Netmask);
        uip_setdraddr(&GatewayIPAddress);
        #endif
-       
+
        /* HTTP Webserver Initialization */
        HTTPServerApp_Init();
-       
+
        /* TELNET Server Initialization */
        #if defined(ENABLE_TELNET_SERVER)
        TELNETServerApp_Init();
@@ -136,7 +138,7 @@ static void uIPManagement_ProcessIncomingPacket(void)
        /* If no packet received, exit processing routine */
        if (!(RNDIS_Host_IsPacketReceived(&Ethernet_RNDIS_Interface)))
          return;
-         
+
        LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
 
        /* Read the Incoming packet straight into the UIP packet buffer */
@@ -162,16 +164,16 @@ static void uIPManagement_ProcessIncomingPacket(void)
 
                                        uip_split_output();
                                }
-                               
+
                                break;
                        case HTONS(UIP_ETHTYPE_ARP):
                                /* Process ARP packet */
                                uip_arp_arpin();
-                               
+
                                /* If a response was generated, send it */
                                if (uip_len > 0)
                                  uip_split_output();
-                               
+
                                break;
                }
        }
@@ -204,7 +206,7 @@ static void uIPManagement_ManageConnections(void)
                timer_reset(&ConnectionTimer);
 
                LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
-               
+
                for (uint8_t i = 0; i < UIP_CONNS; i++)
                {
                        /* Run periodic connection management for each TCP connection */
@@ -220,7 +222,7 @@ static void uIPManagement_ManageConnections(void)
                                uip_split_output();
                        }
                }
-               
+
                #if defined(ENABLE_DHCP_CLIENT)
                for (uint8_t i = 0; i < UIP_UDP_CONNS; i++)
                {
@@ -249,3 +251,4 @@ static void uIPManagement_ManageConnections(void)
                uip_arp_timer();
        }
 }
+