Clean up Webserver project - add more Doxygen documentation for the new DHCP client...
authorDean Camera <dean@fourwalledcubicle.com>
Wed, 27 Jan 2010 13:45:08 +0000 (13:45 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Wed, 27 Jan 2010 13:45:08 +0000 (13:45 +0000)
LUFA/Drivers/Peripheral/AVRU4U6U7/TWI.h
Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c
Projects/Webserver/Lib/DHCPApp.c
Projects/Webserver/Lib/DHCPApp.h
Projects/Webserver/Lib/WebserverApp.h
Projects/Webserver/Lib/uip/conf/uip-conf.h
Projects/Webserver/Webserver.c

index 0247668..b4e1133 100644 (file)
@@ -88,7 +88,7 @@
 \r
                        /** Sends a byte to the currently addressed device on the TWI bus.\r
                         *\r
 \r
                        /** Sends a byte to the currently addressed device on the TWI bus.\r
                         *\r
-                        *  \param Byte  Byte to send to the currently addressed device\r
+                        *  \param[in] Byte  Byte to send to the currently addressed device\r
                         *\r
                         *  \return Boolean true if the recipient ACKed the byte, false otherwise\r
                         */\r
                         *\r
                         *  \return Boolean true if the recipient ACKed the byte, false otherwise\r
                         */\r
 \r
                        /** Receives a byte from the currently addressed device on the TWI bus.\r
                         *\r
 \r
                        /** Receives a byte from the currently addressed device on the TWI bus.\r
                         *\r
-                        *  \param Byte  Location where the read byte is to be stored\r
-                        *  \param LastByte  Indicates if the byte should be ACKed if false, NAKed if true\r
+                        *  \param[in] Byte  Location where the read byte is to be stored\r
+                        *  \param[in] LastByte  Indicates if the byte should be ACKed if false, NAKed if true\r
                         *\r
                         *  \return Boolean true if the byte reception sucessfully completed, false otherwise\r
                         */\r
                         *\r
                         *  \return Boolean true if the byte reception sucessfully completed, false otherwise\r
                         */\r
                /* Function Prototypes: */\r
                        /** Begins a master mode TWI bus communication with the given slave device address.\r
                         *\r
                /* Function Prototypes: */\r
                        /** Begins a master mode TWI bus communication with the given slave device address.\r
                         *\r
-                        *  \param SlaveAddress  Address of the slave TWI device to communicate with\r
+                        *  \param[in] SlaveAddress  Address of the slave TWI device to communicate with\r
                         *\r
                         *  \return Boolean true if the device is ready for data, false otherwise\r
                         */\r
                         *\r
                         *  \return Boolean true if the device is ready for data, false otherwise\r
                         */\r
index c650f0d..9dac31c 100644 (file)
@@ -51,7 +51,7 @@ static void TINYNVM_SendPointerAddress(const uint16_t AbsoluteAddress)
 \r
 /** Sends a SIN command to the target with the specified I/O address, ready for the data byte to be written.\r
  *\r
 \r
 /** Sends a SIN command to the target with the specified I/O address, ready for the data byte to be written.\r
  *\r
- *  \param Address  6-bit I/O address to write to in the target's I/O memory space\r
+ *  \param[in] Address  6-bit I/O address to write to in the target's I/O memory space\r
  */\r
 static void TINYNVM_SendReadNVMRegister(uint8_t Address)\r
 {\r
  */\r
 static void TINYNVM_SendReadNVMRegister(uint8_t Address)\r
 {\r
@@ -62,7 +62,7 @@ static void TINYNVM_SendReadNVMRegister(uint8_t Address)
 \r
 /** Sends a SOUT command to the target with the specified I/O address, ready for the data byte to be read.\r
  *\r
 \r
 /** Sends a SOUT command to the target with the specified I/O address, ready for the data byte to be read.\r
  *\r
- *  \param Address  6-bit I/O address to read from in the target's I/O memory space\r
+ *  \param[in] Address  6-bit I/O address to read from in the target's I/O memory space\r
  */\r
 static void TINYNVM_SendWriteNVMRegister(uint8_t Address)\r
 {\r
  */\r
 static void TINYNVM_SendWriteNVMRegister(uint8_t Address)\r
 {\r
index ec5a815..fe6c6f4 100644 (file)
@@ -36,7 +36,7 @@
  \r
 #include "DHCPApp.h"\r
 \r
  \r
 #include "DHCPApp.h"\r
 \r
-#if defined(ENABLE_DHCP)\r
+#if defined(ENABLE_DHCP) || defined(__DOXYGEN__)\r
 /** Timer for managing the timeout period for a DHCP server to respond */\r
 struct timer DHCPTimer;\r
 \r
 /** Timer for managing the timeout period for a DHCP server to respond */\r
 struct timer DHCPTimer;\r
 \r
@@ -90,10 +90,10 @@ void DHCPApp_Callback(void)
 \r
                        /* Reset the timeout timer, progress to next state */\r
                        timer_reset(&DHCPTimer);\r
 \r
                        /* Reset the timeout timer, progress to next state */\r
                        timer_reset(&DHCPTimer);\r
-                       AppState->CurrentState = DHCP_STATE_WaitForResponse;                    \r
+                       AppState->CurrentState = DHCP_STATE_WaitForOffer;                       \r
                        \r
                        break;\r
                        \r
                        break;\r
-               case DHCP_STATE_WaitForResponse:\r
+               case DHCP_STATE_WaitForOffer:\r
                        if (!(uip_newdata()))\r
                        {\r
                                /* Check if the DHCP timeout period has expired while waiting for a response */\r
                        if (!(uip_newdata()))\r
                        {\r
                                /* Check if the DHCP timeout period has expired while waiting for a response */\r
@@ -166,6 +166,15 @@ void DHCPApp_Callback(void)
        }\r
 }\r
 \r
        }\r
 }\r
 \r
+/** Fills the DHCP packet response with the appropriate BOOTP header for DHCP. This fills out all the required\r
+ *  fields, leaving only the additional DHCP options to be added to the packet before it is sent to the DHCP server.\r
+ *\r
+ *  \param[out] DHCPHeader  Location in the packet buffer where the BOOTP header should be written to\r
+ *  \param[in]  DHCPMessageType  DHCP Message type, such as DHCP_DISCOVER\r
+ *  \param[in]  AppState    Application state of the current UDP connection\r
+ *\r
+ *  \return Size in bytes of the created DHCP packet\r
+ */\r
 uint16_t DHCPApp_FillDHCPHeader(DHCP_Header_t* DHCPHeader, uint8_t DHCPMessageType, uip_udp_appstate_t* AppState)\r
 {\r
        /* Erase existing packet data so that we start will all 0x00 DHCP header data */\r
 uint16_t DHCPApp_FillDHCPHeader(DHCP_Header_t* DHCPHeader, uint8_t DHCPMessageType, uip_udp_appstate_t* AppState)\r
 {\r
        /* Erase existing packet data so that we start will all 0x00 DHCP header data */\r
@@ -195,7 +204,17 @@ uint16_t DHCPApp_FillDHCPHeader(DHCP_Header_t* DHCPHeader, uint8_t DHCPMessageTy
        return (sizeof(DHCP_Header_t) + 4);\r
 }\r
 \r
        return (sizeof(DHCP_Header_t) + 4);\r
 }\r
 \r
-uint8_t DHCPApp_SetOption(uint8_t* DHCPOptionList, uint8_t Option, uint8_t DataLen, void* Source)\r
+/** Sets the given DHCP option in the DHCP packet's option list. This automatically moves the\r
+ *  end of options terminator past the new option in the options list.\r
+ *\r
+ *  \param[in,out] DHCPOptionList  Pointer to the start of the DHCP packet's options list\r
+ *  \param[in]     Option          DHCP option to add to the list\r
+ *  \param[in]     DataLen         Size in bytes of the option data to add\r
+ *  \param[in]     OptionData      Buffer where the option's data is to be sourced from\r
+ *\r
+ *  \return Number of bytes added to the DHCP packet\r
+ */\r
+uint8_t DHCPApp_SetOption(uint8_t* DHCPOptionList, uint8_t Option, uint8_t DataLen, void* OptionData)\r
 {\r
        /* Skip through the DHCP options list until the terminator option is found */\r
        while (*DHCPOptionList != DHCP_OPTION_END)\r
 {\r
        /* Skip through the DHCP options list until the terminator option is found */\r
        while (*DHCPOptionList != DHCP_OPTION_END)\r
@@ -204,13 +223,21 @@ uint8_t DHCPApp_SetOption(uint8_t* DHCPOptionList, uint8_t Option, uint8_t DataL
        /* Overwrite the existing terminator with the new option, add a new terminator at the end of the list */\r
        DHCPOptionList[0] = Option;\r
        DHCPOptionList[1] = DataLen;\r
        /* Overwrite the existing terminator with the new option, add a new terminator at the end of the list */\r
        DHCPOptionList[0] = Option;\r
        DHCPOptionList[1] = DataLen;\r
-       memcpy(&DHCPOptionList[2], Source, DataLen);\r
+       memcpy(&DHCPOptionList[2], OptionData, DataLen);\r
        DHCPOptionList[2 + DataLen] = DHCP_OPTION_END;\r
        \r
        /* Calculate the total number of bytes added to the outgoing packet */\r
        return (2 + DataLen);\r
 }\r
 \r
        DHCPOptionList[2 + DataLen] = DHCP_OPTION_END;\r
        \r
        /* Calculate the total number of bytes added to the outgoing packet */\r
        return (2 + DataLen);\r
 }\r
 \r
+/** Retrieves the given option's data (if present) from the DHCP packet's options list.\r
+ *\r
+ *  \param[in,out] DHCPOptionList  Pointer to the start of the DHCP packet's options list\r
+ *  \param[in]     Option          DHCP option to retrieve to the list\r
+ *  \param[out]    Destination     Buffer where the option's data is to be written to if found\r
+ *\r
+ *  \return Boolean true if the option was found in the DHCP packet's options list, false otherwise\r
+ */\r
 bool DHCPApp_GetOption(uint8_t* DHCPOptionList, uint8_t Option, void* Destination)\r
 {\r
        /* Look through the incomming DHCP packet's options list for the requested option */\r
 bool DHCPApp_GetOption(uint8_t* DHCPOptionList, uint8_t Option, void* Destination)\r
 {\r
        /* Look through the incomming DHCP packet's options list for the requested option */\r
@@ -233,5 +260,4 @@ bool DHCPApp_GetOption(uint8_t* DHCPOptionList, uint8_t Option, void* Destinatio
        /* Requested option not found in the incomming packet's DHCP options list */\r
        return false;\r
 }\r
        /* Requested option not found in the incomming packet's DHCP options list */\r
        return false;\r
 }\r
-\r
 #endif\r
 #endif\r
index 9e9faaa..5d11d82 100644 (file)
                #include "../Webserver.h"\r
                \r
        /* Macros: */\r
                #include "../Webserver.h"\r
                \r
        /* Macros: */\r
+               /** UDP listen port for a BOOTP server */\r
                #define DHCPC_SERVER_PORT         67\r
                #define DHCPC_SERVER_PORT         67\r
+\r
+               /** UDP listen port for a BOOTP client */\r
                #define DHCPC_CLIENT_PORT         68\r
 \r
                #define DHCPC_CLIENT_PORT         68\r
 \r
+               /** BOOTP message type for a BOOTP REQUEST message */\r
                #define DHCP_OP_BOOTREQUEST       0x01\r
                #define DHCP_OP_BOOTREQUEST       0x01\r
+\r
+               /** BOOTP message type for a BOOTP REPLY message */\r
                #define DHCP_OP_BOOTREPLY         0x02\r
 \r
                #define DHCP_OP_BOOTREPLY         0x02\r
 \r
+               /** BOOTP flag for a BOOTP broadcast message */\r
                #define BOOTP_BROADCAST           0x8000\r
                \r
                #define BOOTP_BROADCAST           0x8000\r
                \r
+               /** Magic DHCP cookie for a BOOTP message to identify it as a DHCP message */\r
                #define DHCP_MAGIC_COOKIE         0x63538263\r
                \r
                #define DHCP_MAGIC_COOKIE         0x63538263\r
                \r
+               /** Unique transaction ID used to identify DHCP responses to the client */\r
                #define DHCP_TRANSACTION_ID       0x13245466\r
 \r
                #define DHCP_TRANSACTION_ID       0x13245466\r
 \r
+               /** DHCP message type for a DISCOVER message */\r
                #define DHCP_DISCOVER             1\r
                #define DHCP_DISCOVER             1\r
+\r
+               /** DHCP message type for an OFFER message */\r
                #define DHCP_OFFER                2\r
                #define DHCP_OFFER                2\r
+\r
+               /** DHCP message type for a REQUEST message */\r
                #define DHCP_REQUEST              3\r
                #define DHCP_REQUEST              3\r
+\r
+               /** DHCP message type for a DECLINE message */\r
                #define DHCP_DECLINE              4\r
                #define DHCP_DECLINE              4\r
+\r
+               /** DHCP message type for an ACK message */\r
                #define DHCP_ACK                  5\r
                #define DHCP_ACK                  5\r
+\r
+               /** DHCP message type for a NAK message */\r
                #define DHCP_NAK                  6\r
                #define DHCP_NAK                  6\r
+\r
+               /** DHCP message type for a RELEASE message */\r
                #define DHCP_RELEASE              7\r
 \r
                #define DHCP_RELEASE              7\r
 \r
+               /** DHCP medium type for standard Ethernet */\r
                #define DHCP_HTYPE_ETHERNET       1\r
 \r
                #define DHCP_HTYPE_ETHERNET       1\r
 \r
+               /** DHCP message option for the network subnet mask */\r
                #define DHCP_OPTION_SUBNET_MASK   1\r
                #define DHCP_OPTION_SUBNET_MASK   1\r
+\r
+               /** DHCP message option for the network gateway IP */\r
                #define DHCP_OPTION_ROUTER        3\r
                #define DHCP_OPTION_ROUTER        3\r
+\r
+               /** DHCP message option for the network DNS server */\r
                #define DHCP_OPTION_DNS_SERVER    6\r
                #define DHCP_OPTION_DNS_SERVER    6\r
+\r
+               /** DHCP message option for the requested client IP address */\r
                #define DHCP_OPTION_REQ_IPADDR    50\r
                #define DHCP_OPTION_REQ_IPADDR    50\r
+\r
+               /** DHCP message option for the IP address lease time */\r
                #define DHCP_OPTION_LEASE_TIME    51\r
                #define DHCP_OPTION_LEASE_TIME    51\r
+\r
+               /** DHCP message option for the DHCP message type */\r
                #define DHCP_OPTION_MSG_TYPE      53\r
                #define DHCP_OPTION_MSG_TYPE      53\r
+               \r
+               /** DHCP message option for the DHCP server IP */               \r
                #define DHCP_OPTION_SERVER_ID     54\r
                #define DHCP_OPTION_SERVER_ID     54\r
+\r
+               /** DHCP message option for the list of required options from the server */\r
                #define DHCP_OPTION_REQ_LIST      55\r
                #define DHCP_OPTION_REQ_LIST      55\r
+\r
+               /** DHCP message option for the options list terminator */\r
                #define DHCP_OPTION_END           255\r
 \r
        /* Type Defines: */\r
                #define DHCP_OPTION_END           255\r
 \r
        /* Type Defines: */\r
                } DHCP_Header_t;\r
 \r
        /* Enums: */\r
                } DHCP_Header_t;\r
 \r
        /* Enums: */\r
+               /** States for each DHCP connection to a DHCP client. */\r
                enum DHCP_States_t\r
                {\r
                enum DHCP_States_t\r
                {\r
-                       DHCP_STATE_SendDiscover,\r
-                       DHCP_STATE_WaitForResponse,\r
-                       DHCP_STATE_SendRequest,\r
-                       DHCP_STATE_WaitForACK,\r
-                       DHCP_STATE_AddressLeased,\r
+                       DHCP_STATE_SendDiscover,  /**< Send DISCOVER packet to retrieve DHCP lease offers */\r
+                       DHCP_STATE_WaitForOffer,  /**< Waiting for OFFER packet giving available DHCP leases */\r
+                       DHCP_STATE_SendRequest,   /**< Send REQUEST packet to request a DHCP lease */\r
+                       DHCP_STATE_WaitForACK,    /**< Wait for ACK packet to complete the DHCP lease */\r
+                       DHCP_STATE_AddressLeased, /**< DHCP address has been leased from a DHCP server */\r
                };\r
 \r
        /* Function Prototypes: */\r
                };\r
 \r
        /* Function Prototypes: */\r
                void DHCPApp_Callback(void);\r
                \r
                uint16_t DHCPApp_FillDHCPHeader(DHCP_Header_t* DHCPHeader, uint8_t DHCPMessageType, uip_udp_appstate_t* AppState);\r
                void DHCPApp_Callback(void);\r
                \r
                uint16_t DHCPApp_FillDHCPHeader(DHCP_Header_t* DHCPHeader, uint8_t DHCPMessageType, uip_udp_appstate_t* AppState);\r
-               uint8_t  DHCPApp_SetOption(uint8_t* DHCPOptionList, uint8_t Option, uint8_t DataLen, void* Source);\r
+               uint8_t  DHCPApp_SetOption(uint8_t* DHCPOptionList, uint8_t Option, uint8_t DataLen, void* OptionData);\r
                bool     DHCPApp_GetOption(uint8_t* DHCPOptionList, uint8_t Option, void* Destination);\r
                \r
 #endif\r
                bool     DHCPApp_GetOption(uint8_t* DHCPOptionList, uint8_t Option, void* Destination);\r
                \r
 #endif\r
index 3cb97c6..c788bdb 100644 (file)
                #include <uip.h>\r
                \r
        /* Enums: */\r
                #include <uip.h>\r
                \r
        /* Enums: */\r
+               /** States for each HTTP connection to the webserver. */\r
                enum Webserver_States_t\r
                {\r
                enum Webserver_States_t\r
                {\r
-                       WEBSERVER_STATE_SendHeaders,\r
-                       WEBSERVER_STATE_SendData,\r
-                       WEBSERVER_STATE_Closed,\r
+                       WEBSERVER_STATE_SendHeaders, /**< Currently sending HTTP headers to the client */\r
+                       WEBSERVER_STATE_SendData,    /**< Currently sending HTTP page data to the client */\r
+                       WEBSERVER_STATE_Closed,      /**< Connection closed after all data sent */\r
                };\r
        \r
        /* Macros: */\r
                };\r
        \r
        /* Macros: */\r
+               /** TCP listen port for incomming HTTP traffic */\r
                #define HTTP_SERVER_PORT  80\r
 \r
        /* Function Prototypes: */\r
                #define HTTP_SERVER_PORT  80\r
 \r
        /* Function Prototypes: */\r
index e89e7c4..b13d0e1 100644 (file)
@@ -113,6 +113,12 @@ typedef unsigned short uip_stats_t;
  */\r
 #define UIP_CONF_UDP_CONNS             1\r
 \r
  */\r
 #define UIP_CONF_UDP_CONNS             1\r
 \r
+/**\r
+ *  Host identifier define (e.g. MAC address). If defined as 0,\r
+ *  this will use the internal MAC ethernet address define.\r
+ */\r
+#define UIP_NEIGHBOR_CONF_ADDRTYPE 0\r
+\r
 //Include app configuration\r
 #include "apps-conf.h"\r
 \r
 //Include app configuration\r
 #include "apps-conf.h"\r
 \r
index 78e60f8..ec1dabf 100644 (file)
@@ -149,6 +149,7 @@ int main(void)
        }\r
 }\r
 \r
        }\r
 }\r
 \r
+/** Processes incomming packets to the server from the connected RNDIS device, creating responses as needed. */\r
 void ProcessIncommingPacket(void)\r
 {\r
        if (RNDIS_Host_IsPacketReceived(&Ethernet_RNDIS_Interface))\r
 void ProcessIncommingPacket(void)\r
 {\r
        if (RNDIS_Host_IsPacketReceived(&Ethernet_RNDIS_Interface))\r
@@ -194,6 +195,7 @@ void ProcessIncommingPacket(void)
        }\r
 }\r
 \r
        }\r
 }\r
 \r
+/** Manages the currently open network connections, including TCP and (if enabled) UDP. */\r
 void ManageConnections(void)\r
 {\r
        /* Manage open connections */\r
 void ManageConnections(void)\r
 {\r
        /* Manage open connections */\r