]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.h
Clean codes per ECC.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Dhcp4Dxe / Dhcp4Io.h
index 1caba3ad9e249f7bdf8c24fa1a7dfc2e71625cfa..c041ba87ed8cd66ba791431c5ea224f58d624c22 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-Copyright (c) 2006, Intel Corporation\r
+Copyright (c) 2006 - 2008, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -34,18 +34,21 @@ Abstract:
 #include <Library/MemoryAllocationLib.h>\r
 \r
 \r
-enum {\r
-  DHCP_WAIT_OFFER         = 3,              // Time to wait the offers\r
-  DHCP_DEFAULT_LEASE      = 7 *24 *60 *60,  // Seven days as default.\r
-  DHCP_SERVER_PORT        = 67,\r
-  DHCP_CLIENT_PORT        = 68,\r
 \r
+#define DHCP_WAIT_OFFER                 3  // Time to wait the offers\r
+#define DHCP_DEFAULT_LEASE  7 *24 *60 *60  // Seven days as default.\r
+#define DHCP_SERVER_PORT               67\r
+#define DHCP_CLIENT_PORT               68\r
+\r
+typedef enum {\r
   //\r
   // BOOTP header "op" field\r
   //\r
   BOOTP_REQUEST           = 1,\r
-  BOOTP_REPLY             = 2,\r
+  BOOTP_REPLY             = 2\r
+} DHCP_OP_TYPE;\r
 \r
+typedef enum {\r
   //\r
   // DHCP message types\r
   //\r
@@ -56,21 +59,38 @@ enum {
   DHCP_MSG_ACK            = 5,\r
   DHCP_MSG_NAK            = 6,\r
   DHCP_MSG_RELEASE        = 7,\r
-  DHCP_MSG_INFORM         = 8,\r
+  DHCP_MSG_INFORM         = 8\r
+} DHCP_MSG_TYPE;\r
 \r
+typedef enum {\r
   //\r
   // DHCP notify user type\r
   //\r
   DHCP_NOTIFY_COMPLETION  = 1,\r
   DHCP_NOTIFY_RENEWREBIND,\r
   DHCP_NOTIFY_ALL\r
-};\r
+} DHCP_NOTIFY_TYPE;\r
 \r
 #define DHCP_IS_BOOTP(Parameter)  (((Parameter) == NULL) || ((Parameter)->DhcpType == 0))\r
 \r
 #define DHCP_CONNECTED(State)     \\r
   (((State) == Dhcp4Bound) || ((State) == (Dhcp4Renewing)) || ((State) == Dhcp4Rebinding))\r
 \r
+/**\r
+  Set the DHCP state. If CallUser is true, it will try to notify\r
+  the user before change the state by DhcpNotifyUser. It returns\r
+  EFI_ABORTED if the user return EFI_ABORTED, otherwise, it returns\r
+  EFI_SUCCESS. If CallUser is FALSE, it isn't necessary to test\r
+  the return value of this function.\r
+\r
+  @param  DhcpSb                The DHCP service instance\r
+  @param  State                 The new DHCP state to change to\r
+  @param  CallUser              Whether we need to call user\r
+\r
+  @retval EFI_SUCCESS           The state is changed\r
+  @retval EFI_ABORTED           The user asks to abort the DHCP process.\r
+\r
+**/\r
 EFI_STATUS\r
 DhcpSetState (\r
   IN DHCP_SERVICE           *DhcpSb,\r
@@ -78,6 +98,24 @@ DhcpSetState (
   IN BOOLEAN                CallUser\r
   );\r
 \r
+/**\r
+  Build and transmit a DHCP message according to the current states.\r
+  This function implement the Table 5. of RFC 2131. Always transits\r
+  the state (as defined in Figure 5. of the same RFC) before sending\r
+  a DHCP message. The table is adjusted accordingly.\r
+\r
+  @param  DhcpSb                The DHCP service instance\r
+  @param  Seed                  The seed packet which the new packet is based on\r
+  @param  Para                  The DHCP parameter of the Seed packet\r
+  @param  Type                  The message type to send\r
+  @param  Msg                   The human readable message to include in the packet\r
+                                sent.\r
+\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to allocate resources for the packet\r
+  @retval EFI_ACCESS_DENIED     Failed to transmit the packet through UDP\r
+  @retval EFI_SUCCESS           The message is sent\r
+\r
+**/\r
 EFI_STATUS\r
 DhcpSendMessage (\r
   IN DHCP_SERVICE           *DhcpSb,\r
@@ -87,6 +125,19 @@ DhcpSendMessage (
   IN UINT8                  *Msg\r
   );\r
 \r
+/**\r
+  Each DHCP service has three timer. Two of them are count down timer.\r
+  One for the packet retransmission. The other is to collect the offers.\r
+  The third timer increaments the lease life which is compared to T1, T2,\r
+  and lease to determine the time to renew and rebind the lease.\r
+  DhcpOnTimerTick will be called once every second.\r
+\r
+  @param  Event                 The timer event\r
+  @param  Context               The context, which is the DHCP service instance.\r
+\r
+  @return None\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 DhcpOnTimerTick (\r
@@ -94,6 +145,18 @@ DhcpOnTimerTick (
   IN VOID                   *Context\r
   );\r
 \r
+/**\r
+  Handle the received DHCP packets. This function drivers the DHCP\r
+  state machine.\r
+\r
+  @param  UdpPacket             The UDP packets received.\r
+  @param  Points                The local/remote UDP access points\r
+  @param  IoStatus              The status of the UDP receive\r
+  @param  Context               The opaque parameter to the function.\r
+\r
+  @return None\r
+\r
+**/\r
 VOID\r
 DhcpInput (\r
   NET_BUF                   *UdpPacket,\r
@@ -102,16 +165,44 @@ DhcpInput (
   VOID                      *Context\r
   );\r
 \r
+/**\r
+  Send an initial DISCOVER or REQUEST message according to the\r
+  DHCP service's current state.\r
+\r
+  @param  DhcpSb                The DHCP service instance\r
+\r
+  @retval EFI_SUCCESS           The request has been sent\r
+\r
+**/\r
 EFI_STATUS\r
 DhcpInitRequest (\r
   IN DHCP_SERVICE           *DhcpSb\r
   );\r
 \r
+/**\r
+  Clean up the DHCP related states, IoStatus isn't reset.\r
+\r
+  @param  DhcpSb                The DHCP instance service.\r
+\r
+  @return None\r
+\r
+**/\r
 VOID\r
 DhcpCleanLease (\r
   IN DHCP_SERVICE           *DhcpSb\r
   );\r
 \r
+/**\r
+  Release the net buffer when packet is sent.\r
+\r
+  @param  UdpPacket             The UDP packets received.\r
+  @param  Points                The local/remote UDP access points\r
+  @param  IoStatus              The status of the UDP receive\r
+  @param  Context               The opaque parameter to the function.\r
+\r
+  @return None\r
+\r
+**/\r
 VOID\r
 DhcpOnPacketSent (\r
   NET_BUF                   *Packet,\r