aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-01-27 13:45:08 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-01-27 13:45:08 +0000
commitcec699ac591a679010e07431dfb17823a79856df (patch)
treef7fa9a70db6018a6068f14e7c248893d866bc95f
parenta960e4b3b2ae72c6c3573fb690a1b9cde1642bc0 (diff)
downloadlufa-cec699ac591a679010e07431dfb17823a79856df.tar.gz
lufa-cec699ac591a679010e07431dfb17823a79856df.tar.bz2
lufa-cec699ac591a679010e07431dfb17823a79856df.zip
Clean up Webserver project - add more Doxygen documentation for the new DHCP client functions and defines.
-rw-r--r--LUFA/Drivers/Peripheral/AVRU4U6U7/TWI.h8
-rw-r--r--Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c4
-rw-r--r--Projects/Webserver/Lib/DHCPApp.c38
-rw-r--r--Projects/Webserver/Lib/DHCPApp.h53
-rw-r--r--Projects/Webserver/Lib/WebserverApp.h8
-rw-r--r--Projects/Webserver/Lib/uip/conf/uip-conf.h6
-rw-r--r--Projects/Webserver/Webserver.c2
7 files changed, 98 insertions, 21 deletions
diff --git a/LUFA/Drivers/Peripheral/AVRU4U6U7/TWI.h b/LUFA/Drivers/Peripheral/AVRU4U6U7/TWI.h
index 0247668dc..b4e113373 100644
--- a/LUFA/Drivers/Peripheral/AVRU4U6U7/TWI.h
+++ b/LUFA/Drivers/Peripheral/AVRU4U6U7/TWI.h
@@ -88,7 +88,7 @@
/** Sends a byte to the currently addressed device on the TWI bus.
*
- * \param Byte Byte to send to the currently addressed device
+ * \param[in] Byte Byte to send to the currently addressed device
*
* \return Boolean true if the recipient ACKed the byte, false otherwise
*/
@@ -103,8 +103,8 @@
/** Receives a byte from the currently addressed device on the TWI bus.
*
- * \param Byte Location where the read byte is to be stored
- * \param LastByte Indicates if the byte should be ACKed if false, NAKed if true
+ * \param[in] Byte Location where the read byte is to be stored
+ * \param[in] LastByte Indicates if the byte should be ACKed if false, NAKed if true
*
* \return Boolean true if the byte reception sucessfully completed, false otherwise
*/
@@ -125,7 +125,7 @@
/* Function Prototypes: */
/** Begins a master mode TWI bus communication with the given slave device address.
*
- * \param SlaveAddress Address of the slave TWI device to communicate with
+ * \param[in] SlaveAddress Address of the slave TWI device to communicate with
*
* \return Boolean true if the device is ready for data, false otherwise
*/
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c b/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c
index c650f0dd8..9dac31ca2 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c
+++ b/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c
@@ -51,7 +51,7 @@ static void TINYNVM_SendPointerAddress(const uint16_t AbsoluteAddress)
/** Sends a SIN command to the target with the specified I/O address, ready for the data byte to be written.
*
- * \param Address 6-bit I/O address to write to in the target's I/O memory space
+ * \param[in] Address 6-bit I/O address to write to in the target's I/O memory space
*/
static void TINYNVM_SendReadNVMRegister(uint8_t Address)
{
@@ -62,7 +62,7 @@ static void TINYNVM_SendReadNVMRegister(uint8_t Address)
/** Sends a SOUT command to the target with the specified I/O address, ready for the data byte to be read.
*
- * \param Address 6-bit I/O address to read from in the target's I/O memory space
+ * \param[in] Address 6-bit I/O address to read from in the target's I/O memory space
*/
static void TINYNVM_SendWriteNVMRegister(uint8_t Address)
{
diff --git a/Projects/Webserver/Lib/DHCPApp.c b/Projects/Webserver/Lib/DHCPApp.c
index ec5a815ef..fe6c6f457 100644
--- a/Projects/Webserver/Lib/DHCPApp.c
+++ b/Projects/Webserver/Lib/DHCPApp.c
@@ -36,7 +36,7 @@
#include "DHCPApp.h"
-#if defined(ENABLE_DHCP)
+#if defined(ENABLE_DHCP) || defined(__DOXYGEN__)
/** Timer for managing the timeout period for a DHCP server to respond */
struct timer DHCPTimer;
@@ -90,10 +90,10 @@ void DHCPApp_Callback(void)
/* Reset the timeout timer, progress to next state */
timer_reset(&DHCPTimer);
- AppState->CurrentState = DHCP_STATE_WaitForResponse;
+ AppState->CurrentState = DHCP_STATE_WaitForOffer;
break;
- case DHCP_STATE_WaitForResponse:
+ case DHCP_STATE_WaitForOffer:
if (!(uip_newdata()))
{
/* Check if the DHCP timeout period has expired while waiting for a response */
@@ -166,6 +166,15 @@ void DHCPApp_Callback(void)
}
}
+/** Fills the DHCP packet response with the appropriate BOOTP header for DHCP. This fills out all the required
+ * fields, leaving only the additional DHCP options to be added to the packet before it is sent to the DHCP server.
+ *
+ * \param[out] DHCPHeader Location in the packet buffer where the BOOTP header should be written to
+ * \param[in] DHCPMessageType DHCP Message type, such as DHCP_DISCOVER
+ * \param[in] AppState Application state of the current UDP connection
+ *
+ * \return Size in bytes of the created DHCP packet
+ */
uint16_t DHCPApp_FillDHCPHeader(DHCP_Header_t* DHCPHeader, uint8_t DHCPMessageType, uip_udp_appstate_t* AppState)
{
/* Erase existing packet data so that we start will all 0x00 DHCP header data */
@@ -195,7 +204,17 @@ uint16_t DHCPApp_FillDHCPHeader(DHCP_Header_t* DHCPHeader, uint8_t DHCPMessageTy
return (sizeof(DHCP_Header_t) + 4);
}
-uint8_t DHCPApp_SetOption(uint8_t* DHCPOptionList, uint8_t Option, uint8_t DataLen, void* Source)
+/** Sets the given DHCP option in the DHCP packet's option list. This automatically moves the
+ * end of options terminator past the new option in the options list.
+ *
+ * \param[in,out] DHCPOptionList Pointer to the start of the DHCP packet's options list
+ * \param[in] Option DHCP option to add to the list
+ * \param[in] DataLen Size in bytes of the option data to add
+ * \param[in] OptionData Buffer where the option's data is to be sourced from
+ *
+ * \return Number of bytes added to the DHCP packet
+ */
+uint8_t DHCPApp_SetOption(uint8_t* DHCPOptionList, uint8_t Option, uint8_t DataLen, void* OptionData)
{
/* Skip through the DHCP options list until the terminator option is found */
while (*DHCPOptionList != DHCP_OPTION_END)
@@ -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 */
DHCPOptionList[0] = Option;
DHCPOptionList[1] = DataLen;
- memcpy(&DHCPOptionList[2], Source, DataLen);
+ memcpy(&DHCPOptionList[2], OptionData, DataLen);
DHCPOptionList[2 + DataLen] = DHCP_OPTION_END;
/* Calculate the total number of bytes added to the outgoing packet */
return (2 + DataLen);
}
+/** Retrieves the given option's data (if present) from the DHCP packet's options list.
+ *
+ * \param[in,out] DHCPOptionList Pointer to the start of the DHCP packet's options list
+ * \param[in] Option DHCP option to retrieve to the list
+ * \param[out] Destination Buffer where the option's data is to be written to if found
+ *
+ * \return Boolean true if the option was found in the DHCP packet's options list, false otherwise
+ */
bool DHCPApp_GetOption(uint8_t* DHCPOptionList, uint8_t Option, void* Destination)
{
/* Look through the incomming DHCP packet's options list for the requested option */
@@ -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 */
return false;
}
-
#endif
diff --git a/Projects/Webserver/Lib/DHCPApp.h b/Projects/Webserver/Lib/DHCPApp.h
index 9e9faaa36..5d11d8236 100644
--- a/Projects/Webserver/Lib/DHCPApp.h
+++ b/Projects/Webserver/Lib/DHCPApp.h
@@ -44,36 +44,76 @@
#include "../Webserver.h"
/* Macros: */
+ /** UDP listen port for a BOOTP server */
#define DHCPC_SERVER_PORT 67
+
+ /** UDP listen port for a BOOTP client */
#define DHCPC_CLIENT_PORT 68
+ /** BOOTP message type for a BOOTP REQUEST message */
#define DHCP_OP_BOOTREQUEST 0x01
+
+ /** BOOTP message type for a BOOTP REPLY message */
#define DHCP_OP_BOOTREPLY 0x02
+ /** BOOTP flag for a BOOTP broadcast message */
#define BOOTP_BROADCAST 0x8000
+ /** Magic DHCP cookie for a BOOTP message to identify it as a DHCP message */
#define DHCP_MAGIC_COOKIE 0x63538263
+ /** Unique transaction ID used to identify DHCP responses to the client */
#define DHCP_TRANSACTION_ID 0x13245466
+ /** DHCP message type for a DISCOVER message */
#define DHCP_DISCOVER 1
+
+ /** DHCP message type for an OFFER message */
#define DHCP_OFFER 2
+
+ /** DHCP message type for a REQUEST message */
#define DHCP_REQUEST 3
+
+ /** DHCP message type for a DECLINE message */
#define DHCP_DECLINE 4
+
+ /** DHCP message type for an ACK message */
#define DHCP_ACK 5
+
+ /** DHCP message type for a NAK message */
#define DHCP_NAK 6
+
+ /** DHCP message type for a RELEASE message */
#define DHCP_RELEASE 7
+ /** DHCP medium type for standard Ethernet */
#define DHCP_HTYPE_ETHERNET 1
+ /** DHCP message option for the network subnet mask */
#define DHCP_OPTION_SUBNET_MASK 1
+
+ /** DHCP message option for the network gateway IP */
#define DHCP_OPTION_ROUTER 3
+
+ /** DHCP message option for the network DNS server */
#define DHCP_OPTION_DNS_SERVER 6
+
+ /** DHCP message option for the requested client IP address */
#define DHCP_OPTION_REQ_IPADDR 50
+
+ /** DHCP message option for the IP address lease time */
#define DHCP_OPTION_LEASE_TIME 51
+
+ /** DHCP message option for the DHCP message type */
#define DHCP_OPTION_MSG_TYPE 53
+
+ /** DHCP message option for the DHCP server IP */
#define DHCP_OPTION_SERVER_ID 54
+
+ /** DHCP message option for the list of required options from the server */
#define DHCP_OPTION_REQ_LIST 55
+
+ /** DHCP message option for the options list terminator */
#define DHCP_OPTION_END 255
/* Type Defines: */
@@ -105,13 +145,14 @@
} DHCP_Header_t;
/* Enums: */
+ /** States for each DHCP connection to a DHCP client. */
enum DHCP_States_t
{
- DHCP_STATE_SendDiscover,
- DHCP_STATE_WaitForResponse,
- DHCP_STATE_SendRequest,
- DHCP_STATE_WaitForACK,
- DHCP_STATE_AddressLeased,
+ DHCP_STATE_SendDiscover, /**< Send DISCOVER packet to retrieve DHCP lease offers */
+ DHCP_STATE_WaitForOffer, /**< Waiting for OFFER packet giving available DHCP leases */
+ DHCP_STATE_SendRequest, /**< Send REQUEST packet to request a DHCP lease */
+ DHCP_STATE_WaitForACK, /**< Wait for ACK packet to complete the DHCP lease */
+ DHCP_STATE_AddressLeased, /**< DHCP address has been leased from a DHCP server */
};
/* Function Prototypes: */
@@ -119,7 +160,7 @@
void DHCPApp_Callback(void);
uint16_t DHCPApp_FillDHCPHeader(DHCP_Header_t* DHCPHeader, uint8_t DHCPMessageType, uip_udp_appstate_t* AppState);
- uint8_t DHCPApp_SetOption(uint8_t* DHCPOptionList, uint8_t Option, uint8_t DataLen, void* Source);
+ uint8_t DHCPApp_SetOption(uint8_t* DHCPOptionList, uint8_t Option, uint8_t DataLen, void* OptionData);
bool DHCPApp_GetOption(uint8_t* DHCPOptionList, uint8_t Option, void* Destination);
#endif
diff --git a/Projects/Webserver/Lib/WebserverApp.h b/Projects/Webserver/Lib/WebserverApp.h
index 3cb97c667..c788bdbeb 100644
--- a/Projects/Webserver/Lib/WebserverApp.h
+++ b/Projects/Webserver/Lib/WebserverApp.h
@@ -45,14 +45,16 @@
#include <uip.h>
/* Enums: */
+ /** States for each HTTP connection to the webserver. */
enum Webserver_States_t
{
- WEBSERVER_STATE_SendHeaders,
- WEBSERVER_STATE_SendData,
- WEBSERVER_STATE_Closed,
+ WEBSERVER_STATE_SendHeaders, /**< Currently sending HTTP headers to the client */
+ WEBSERVER_STATE_SendData, /**< Currently sending HTTP page data to the client */
+ WEBSERVER_STATE_Closed, /**< Connection closed after all data sent */
};
/* Macros: */
+ /** TCP listen port for incomming HTTP traffic */
#define HTTP_SERVER_PORT 80
/* Function Prototypes: */
diff --git a/Projects/Webserver/Lib/uip/conf/uip-conf.h b/Projects/Webserver/Lib/uip/conf/uip-conf.h
index e89e7c4c6..b13d0e19f 100644
--- a/Projects/Webserver/Lib/uip/conf/uip-conf.h
+++ b/Projects/Webserver/Lib/uip/conf/uip-conf.h
@@ -113,6 +113,12 @@ typedef unsigned short uip_stats_t;
*/
#define UIP_CONF_UDP_CONNS 1
+/**
+ * Host identifier define (e.g. MAC address). If defined as 0,
+ * this will use the internal MAC ethernet address define.
+ */
+#define UIP_NEIGHBOR_CONF_ADDRTYPE 0
+
//Include app configuration
#include "apps-conf.h"
diff --git a/Projects/Webserver/Webserver.c b/Projects/Webserver/Webserver.c
index 78e60f866..ec1dabffb 100644
--- a/Projects/Webserver/Webserver.c
+++ b/Projects/Webserver/Webserver.c
@@ -149,6 +149,7 @@ int main(void)
}
}
+/** Processes incomming packets to the server from the connected RNDIS device, creating responses as needed. */
void ProcessIncommingPacket(void)
{
if (RNDIS_Host_IsPacketReceived(&Ethernet_RNDIS_Interface))
@@ -194,6 +195,7 @@ void ProcessIncommingPacket(void)
}
}
+/** Manages the currently open network connections, including TCP and (if enabled) UDP. */
void ManageConnections(void)
{
/* Manage open connections */