]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c
Update NewHii library
[mirror_edk2.git] / MdeModulePkg / Library / DxeIpIoLib / DxeIpIoLib.c
index 4674d7d028aa49f8ad9d93ad53dce93ed6fdfded..f37bb91ad8cf78cb508d0f066225d200ddec4b94 100644 (file)
@@ -1,6 +1,7 @@
 /** @file\r
+  IpIo Library.\r
 \r
-Copyright (c) 2005 - 2007, Intel Corporation\r
+Copyright (c) 2005 - 2007, Intel Corporation.<BR>\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
@@ -8,19 +9,9 @@ http://opensource.org/licenses/bsd-license.php
 \r
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-Module Name:\r
-\r
-  IpIo.c\r
-\r
-Abstract:\r
-\r
-  The implementation of the IpIo layer.\r
-\r
-\r
 **/\r
 \r
-#include <PiDxe.h>\r
+#include <Uefi.h>\r
 \r
 #include <Protocol/Udp4.h>\r
 \r
@@ -28,13 +19,7 @@ Abstract:
 #include <Library/BaseLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-\r
 \r
-#define NET_PROTO_HDR(Buf, Type)  ((Type *) ((Buf)->BlockOp[0].Head))\r
-#define ICMP_ERRLEN(IpHdr) \\r
-  (sizeof(IP4_ICMP_HEAD) + EFI_IP4_HEADER_LEN(IpHdr) + 8)\r
 \r
 LIST_ENTRY  mActiveIpIoList = {\r
   &mActiveIpIoList,\r
@@ -58,7 +43,7 @@ EFI_IP4_CONFIG_DATA  mIpIoDefaultIpConfigData = {
   0\r
 };\r
 \r
-STATIC ICMP_ERROR_INFO  mIcmpErrMap[10] = {\r
+ICMP_ERROR_INFO  mIcmpErrMap[10] = {\r
   {FALSE, TRUE},\r
   {FALSE, TRUE},\r
   {TRUE, TRUE},\r
@@ -71,14 +56,27 @@ STATIC ICMP_ERROR_INFO  mIcmpErrMap[10] = {
   {FALSE, TRUE}\r
 };\r
 \r
-STATIC\r
+\r
+/**\r
+  Notify function for IP transmit token.\r
+\r
+  @param[in]  Context               The context passed in by the event notifier.\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 IpIoTransmitHandlerDpc (\r
   IN VOID      *Context\r
   );\r
 \r
-STATIC\r
+\r
+/**\r
+  Notify function for IP transmit token.\r
+\r
+  @param[in]  Event                 The event signaled.\r
+  @param[in]  Context               The context passed in by the event notifier.\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 IpIoTransmitHandler (\r
@@ -88,20 +86,19 @@ IpIoTransmitHandler (
 \r
 \r
 /**\r
-  This function create an ip child ,open the IP protocol, return the opened\r
-  Ip protocol to Interface.\r
+  This function create an IP child ,open the IP protocol, and return the opened\r
+  IP protocol as Interface.\r
 \r
-  @param  ControllerHandle      The controller handle.\r
-  @param  ImageHandle           The image handle.\r
-  @param  ChildHandle           Pointer to the buffer to save the ip child handle.\r
-  @param  Interface             Pointer used to get the ip protocol interface.\r
+  @param[in]    ControllerHandle   The controller handle.\r
+  @param[in]    ImageHandle        The image handle.\r
+  @param[in]    ChildHandle        Pointer to the buffer to save the IP child handle.\r
+  @param[out]   Interface          Pointer used to get the IP protocol interface.\r
 \r
-  @retval EFI_SUCCESS           The ip child is created and the ip protocol\r
-                                interface is retrieved.\r
-  @retval other                 The required operation failed.\r
+  @retval       EFI_SUCCESS        The IP child is created and the IP protocol\r
+                                   interface is retrieved.\r
+  @retval       Others             The required operation failed.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 IpIoCreateIpChildOpenProtocol (\r
   IN  EFI_HANDLE  ControllerHandle,\r
@@ -113,7 +110,7 @@ IpIoCreateIpChildOpenProtocol (
   EFI_STATUS  Status;\r
 \r
   //\r
-  // Create an ip child.\r
+  // Create an IP child.\r
   //\r
   Status = NetLibCreateServiceChild (\r
              ControllerHandle,\r
@@ -126,7 +123,7 @@ IpIoCreateIpChildOpenProtocol (
   }\r
 \r
   //\r
-  // Open the ip protocol installed on the *ChildHandle.\r
+  // Open the IP protocol installed on the *ChildHandle.\r
   //\r
   Status = gBS->OpenProtocol (\r
                   *ChildHandle,\r
@@ -138,7 +135,7 @@ IpIoCreateIpChildOpenProtocol (
                   );\r
   if (EFI_ERROR (Status)) {\r
     //\r
-    // On failure, destroy the ip child.\r
+    // On failure, destroy the IP child.\r
     //\r
     NetLibDestroyServiceChild (\r
       ControllerHandle,\r
@@ -153,18 +150,17 @@ IpIoCreateIpChildOpenProtocol (
 \r
 \r
 /**\r
-  This function close the previously openned ip protocol and destroy the ip child.\r
+  This function close the previously openned IP protocol and destroy the IP child.\r
 \r
-  @param  ControllerHandle      The controller handle.\r
-  @param  ImageHandle           the image handle.\r
-  @param  ChildHandle           The child handle of the ip child.\r
+  @param[in]  ControllerHandle    The controller handle.\r
+  @param[in]  ImageHandle         The image handle.\r
+  @param[in]  ChildHandle         The child handle of the IP child.\r
 \r
-  @retval EFI_SUCCESS           The ip protocol is closed and the relevant ip child\r
-                                is destroyed.\r
-  @retval other                 The required operation failed.\r
+  @retval     EFI_SUCCESS         The IP protocol is closed and the relevant IP child\r
+                                  is destroyed.\r
+  @retval     Others              The required operation failed.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 IpIoCloseProtocolDestroyIpChild (\r
   IN EFI_HANDLE  ControllerHandle,\r
@@ -175,7 +171,7 @@ IpIoCloseProtocolDestroyIpChild (
   EFI_STATUS  Status;\r
 \r
   //\r
-  // Close the previously openned ip protocol.\r
+  // Close the previously openned IP protocol.\r
   //\r
   gBS->CloseProtocol (\r
          ChildHandle,\r
@@ -185,7 +181,7 @@ IpIoCloseProtocolDestroyIpChild (
          );\r
 \r
   //\r
-  // Destroy the ip child.\r
+  // Destroy the IP child.\r
   //\r
   Status = NetLibDestroyServiceChild (\r
              ControllerHandle,\r
@@ -199,22 +195,21 @@ IpIoCloseProtocolDestroyIpChild (
 \r
 \r
 /**\r
-  Handle ICMP packets.\r
+  This function handles ICMP packets.\r
 \r
-  @param  IpIo                  Pointer to the IP_IO instance.\r
-  @param  Pkt                   Pointer to the ICMP packet.\r
-  @param  Session               Pointer to the net session of this ICMP packet.\r
+  @param[in]       IpIo          Pointer to the IP_IO instance.\r
+  @param[in, out]  Pkt           Pointer to the ICMP packet.\r
+  @param[in]       Session       Pointer to the net session of this ICMP packet.\r
 \r
-  @retval EFI_SUCCESS           The ICMP packet is handled successfully.\r
-  @retval EFI_ABORTED           This type of ICMP packet is not supported.\r
+  @retval          EFI_SUCCESS   The ICMP packet is handled successfully.\r
+  @retval          EFI_ABORTED   This type of ICMP packet is not supported.\r
 \r
 **/\r
-STATIC\r
 EFI_STATUS\r
 IpIoIcmpHandler (\r
-  IN IP_IO                *IpIo,\r
-  IN NET_BUF              *Pkt,\r
-  IN EFI_NET_SESSION_DATA *Session\r
+  IN     IP_IO                *IpIo,\r
+  IN OUT NET_BUF              *Pkt,\r
+  IN     EFI_NET_SESSION_DATA *Session\r
   )\r
 {\r
   IP4_ICMP_ERROR_HEAD  *IcmpHdr;\r
@@ -276,8 +271,6 @@ IpIoIcmpHandler (
 \r
     default:\r
       return EFI_ABORTED;\r
-\r
-      break;\r
     }\r
 \r
     break;\r
@@ -311,8 +304,6 @@ IpIoIcmpHandler (
 \r
   default:\r
     return EFI_ABORTED;\r
-\r
-    break;\r
   }\r
 \r
   //\r
@@ -331,17 +322,13 @@ IpIoIcmpHandler (
 \r
 \r
 /**\r
-  Ext free function for net buffer. This function is\r
-  called when the net buffer is freed. It is used to\r
+  Free function for receive token of IP_IO. It is used to\r
   signal the recycle event to notify IP to recycle the\r
   data buffer.\r
 \r
-  @param  Event                 The event to be signaled.\r
-\r
-  @return None.\r
+  @param[in]  Event                 The event to be signaled.\r
 \r
 **/\r
-STATIC\r
 VOID\r
 IpIoExtFree (\r
   IN VOID  *Event\r
@@ -355,27 +342,27 @@ IpIoExtFree (
   Create a send entry to wrap a packet before sending\r
   out it through IP.\r
 \r
-  @param  IpIo                  Pointer to the IP_IO instance.\r
-  @param  Pkt                   Pointer to the packet.\r
-  @param  Sender                Pointer to the IP sender.\r
-  @param  NotifyData            Pointer to the notify data.\r
-  @param  Dest                  Pointer to the destination IP address.\r
-  @param  Override              Pointer to the overriden IP_IO data.\r
+  @param[in, out]  IpIo                 Pointer to the IP_IO instance.\r
+  @param[in, out]  Pkt                  Pointer to the packet.\r
+  @param[in]       Sender               Pointer to the IP sender.\r
+  @param[in]       Context              Pointer to the context.\r
+  @param[in]       NotifyData           Pointer to the notify data.\r
+  @param[in]       Dest                 Pointer to the destination IP address.\r
+  @param[in]       Override             Pointer to the overriden IP_IO data.\r
 \r
   @return Pointer to the data structure created to wrap the packet. If NULL,\r
   @return resource limit occurred.\r
 \r
 **/\r
-STATIC\r
 IP_IO_SEND_ENTRY *\r
 IpIoCreateSndEntry (\r
-  IN IP_IO             *IpIo,\r
-  IN NET_BUF           *Pkt,\r
-  IN EFI_IP4_PROTOCOL  *Sender,\r
-  IN VOID              *Context    OPTIONAL,\r
-  IN VOID              *NotifyData OPTIONAL,\r
-  IN IP4_ADDR          Dest,\r
-  IN IP_IO_OVERRIDE    *Override\r
+  IN OUT IP_IO             *IpIo,\r
+  IN OUT NET_BUF           *Pkt,\r
+  IN     EFI_IP4_PROTOCOL  *Sender,\r
+  IN     VOID              *Context    OPTIONAL,\r
+  IN     VOID              *NotifyData OPTIONAL,\r
+  IN     IP4_ADDR          Dest,\r
+  IN     IP_IO_OVERRIDE    *Override\r
   )\r
 {\r
   IP_IO_SEND_ENTRY          *SndEntry;\r
@@ -465,7 +452,7 @@ IpIoCreateSndEntry (
   // Set the fields of SndEntry\r
   //\r
   SndEntry->IpIo        = IpIo;\r
-  SndEntry->Ip      = Sender;\r
+  SndEntry->Ip          = Sender;\r
   SndEntry->Context     = Context;\r
   SndEntry->NotifyData  = NotifyData;\r
 \r
@@ -496,13 +483,12 @@ ReleaseSndEntry:
 \r
 /**\r
   Destroy the SndEntry.\r
+  \r
+  This function pairs with IpIoCreateSndEntry().\r
 \r
-  @param  SndEntry              Pointer to the send entry to be destroyed.\r
-\r
-  @return None.\r
+  @param[in]  SndEntry              Pointer to the send entry to be destroyed.\r
 \r
 **/\r
-STATIC\r
 VOID\r
 IpIoDestroySndEntry (\r
   IN IP_IO_SEND_ENTRY  *SndEntry\r
@@ -530,12 +516,9 @@ IpIoDestroySndEntry (
 /**\r
   Notify function for IP transmit token.\r
 \r
-  @param  Context               The context passed in by the event notifier.\r
-\r
-  @return None.\r
+  @param[in]  Context               The context passed in by the event notifier.\r
 \r
 **/\r
-STATIC\r
 VOID\r
 EFIAPI\r
 IpIoTransmitHandlerDpc (\r
@@ -549,7 +532,7 @@ IpIoTransmitHandlerDpc (
 \r
   IpIo      = SndEntry->IpIo;\r
 \r
-  if (IpIo->PktSentNotify && SndEntry->NotifyData) {\r
+  if ((IpIo->PktSentNotify != NULL) && (SndEntry->NotifyData != NULL)) {\r
     IpIo->PktSentNotify (\r
             SndEntry->SndToken->Status,\r
             SndEntry->Context,\r
@@ -561,17 +544,14 @@ IpIoTransmitHandlerDpc (
   IpIoDestroySndEntry (SndEntry);\r
 }\r
 \r
+\r
 /**\r
   Notify function for IP transmit token.\r
 \r
-  @param  Event                 The event signaled.\r
-  @param  Context               The context passed in by the event notifier.\r
-\r
-  @return None.\r
+  @param[in]  Event                 The event signaled.\r
+  @param[in]  Context               The context passed in by the event notifier.\r
 \r
 **/\r
-\r
-STATIC\r
 VOID\r
 EFIAPI\r
 IpIoTransmitHandler (\r
@@ -589,12 +569,9 @@ IpIoTransmitHandler (
 /**\r
   The dummy handler for the dummy IP receive token.\r
 \r
-  @param  Context               The context passed in by the event notifier.\r
-\r
-  @return None.\r
+  @param[in]  Context               The context passed in by the event notifier.\r
 \r
 **/\r
-STATIC\r
 VOID\r
 EFIAPI\r
 IpIoDummyHandlerDpc (\r
@@ -613,7 +590,7 @@ IpIoDummyHandlerDpc (
     //\r
     return;\r
   } else if (EFI_SUCCESS == DummyToken->Status) {\r
-    ASSERT (DummyToken->Packet.RxData);\r
+    ASSERT ((DummyToken->Packet.RxData)!= NULL);\r
 \r
     gBS->SignalEvent (DummyToken->Packet.RxData->RecycleSignal);\r
   }\r
@@ -623,15 +600,12 @@ IpIoDummyHandlerDpc (
 \r
 \r
 /**\r
-  Request IpIoDummyHandlerDpc as a DPC at TPL_CALLBACK.\r
-\r
-  @param  Event                 The event signaled.\r
-  @param  Context               The context passed in by the event notifier.\r
+  This function add IpIoDummyHandlerDpc to the end of the DPC queue.\r
 \r
-  @return None.\r
+  @param[in]  Event                 The event signaled.\r
+  @param[in]  Context               The context passed in by the event notifier.\r
 \r
 **/\r
-STATIC\r
 VOID\r
 EFIAPI\r
 IpIoDummyHandler (\r
@@ -650,12 +624,9 @@ IpIoDummyHandler (
   Notify function for the IP receive token, used to process\r
   the received IP packets.\r
 \r
-  @param  Context               The context passed in by the event notifier.\r
-\r
-  @return None.\r
+  @param[in]  Context               The context passed in by the event notifier.\r
 \r
 **/\r
-STATIC\r
 VOID\r
 EFIAPI\r
 IpIoListenHandlerDpc (\r
@@ -684,9 +655,9 @@ IpIoListenHandlerDpc (
 \r
   if (((EFI_SUCCESS != Status) && (EFI_ICMP_ERROR != Status)) || (NULL == RxData)) {\r
     //\r
-    // Only process the normal packets and the icmp error packets, if RxData is NULL\r
-    // with Status == EFI_SUCCESS or EFI_ICMP_ERROR, just resume the receive although\r
-    // this should be a bug of the low layer (IP).\r
+    // @bug Only process the normal packets and the icmp error packets, if RxData is NULL\r
+    // @bug with Status == EFI_SUCCESS or EFI_ICMP_ERROR, just resume the receive although\r
+    // @bug this should be a bug of the low layer (IP).\r
     //\r
     goto Resume;\r
   }\r
@@ -749,15 +720,12 @@ Resume:
 \r
 \r
 /**\r
-  Request IpIoListenHandlerDpc as a DPC at TPL_CALLBACK\r
+  This function add IpIoListenHandlerDpc to the end of the DPC queue.\r
 \r
-  @param  Event                 The event signaled.\r
-  @param  Context               The context passed in by the event notifier.\r
-\r
-  @return None.\r
+  @param[in]  Event                The event signaled.\r
+  @param[in]  Context              The context passed in by the event notifier.\r
 \r
 **/\r
-STATIC\r
 VOID\r
 EFIAPI\r
 IpIoListenHandler (\r
@@ -774,15 +742,20 @@ IpIoListenHandler (
 \r
 /**\r
   Create a new IP_IO instance.\r
+  \r
+  This function uses IP4 service binding protocol in Controller to create an IP4\r
+  child (aka IP4 instance).\r
 \r
-  @param  Image                 The image handle of an IP_IO consumer protocol.\r
-  @param  Controller            The controller handle of an IP_IO consumer protocol\r
-                                installed on.\r
+  @param[in]  Image             The image handle of the driver or application that\r
+                                consumes IP_IO.\r
+  @param[in]  Controller        The controller handle that has IP4 service binding\r
+                                protocol installed.\r
 \r
-  @return Pointer to a newly created IP_IO instance.\r
+  @return Pointer to a newly created IP_IO instance, or NULL if failed.\r
 \r
 **/\r
 IP_IO *\r
+EFIAPI\r
 IpIoCreate (\r
   IN EFI_HANDLE Image,\r
   IN EFI_HANDLE Controller\r
@@ -841,19 +814,28 @@ ReleaseIpIo:
 \r
 /**\r
   Open an IP_IO instance for use.\r
-\r
-  @param  IpIo                  Pointer to an IP_IO instance that needs to open.\r
-  @param  OpenData              The configuration data for the IP_IO instance.\r
-\r
-  @retval EFI_SUCCESS           The IP_IO instance opened with OpenData\r
-                                successfully.\r
-  @retval other                 Error condition occurred.\r
+  \r
+  This function is called after IpIoCreate(). It is used for configuring the IP\r
+  instance and register the callbacks and their context data for sending and\r
+  receiving IP packets.\r
+\r
+  @param[in, out]  IpIo               Pointer to an IP_IO instance that needs\r
+                                      to open.\r
+  @param[in]       OpenData           The configuration data and callbacks for\r
+                                      the IP_IO instance.\r
+\r
+  @retval          EFI_SUCCESS        The IP_IO instance opened with OpenData\r
+                                      successfully.\r
+  @retval          EFI_ACCESS_DENIED  The IP_IO instance is configured, avoid to \r
+                                      reopen it.\r
+  @retval          Others             Error condition occurred.\r
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 IpIoOpen (\r
-  IN IP_IO           *IpIo,\r
-  IN IP_IO_OPEN_DATA *OpenData\r
+  IN OUT IP_IO           *IpIo,\r
+  IN     IP_IO_OPEN_DATA *OpenData\r
   )\r
 {\r
   EFI_STATUS        Status;\r
@@ -874,9 +856,9 @@ IpIoOpen (
   }\r
 \r
   //\r
-  // bugbug: to delete the default route entry in this Ip, if it is:\r
-  // (0.0.0.0, 0.0.0.0, 0.0.0.0). Delete this statement if Ip modified\r
-  // its code\r
+  // @bug To delete the default route entry in this Ip, if it is:\r
+  // @bug (0.0.0.0, 0.0.0.0, 0.0.0.0). Delete this statement if Ip modified\r
+  // @bug its code\r
   //\r
   Status = Ip->Routes (Ip, TRUE, &mZeroIp4Addr, &mZeroIp4Addr, &mZeroIp4Addr);\r
 \r
@@ -912,16 +894,20 @@ ErrorExit:
 \r
 /**\r
   Stop an IP_IO instance.\r
+  \r
+  This function is paired with IpIoOpen(). The IP_IO will be unconfigured and all\r
+  the pending send/receive tokens will be canceled.\r
 \r
-  @param  IpIo                  Pointer to the IP_IO instance that needs to stop.\r
+  @param[in, out]  IpIo            Pointer to the IP_IO instance that needs to stop.\r
 \r
-  @retval EFI_SUCCESS           The IP_IO instance stopped successfully.\r
-  @retval other                 Error condition occurred.\r
+  @retval          EFI_SUCCESS     The IP_IO instance stopped successfully.\r
+  @retval          Others          Error condition occurred.\r
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 IpIoStop (\r
-  IN IP_IO *IpIo\r
+  IN OUT IP_IO *IpIo\r
   )\r
 {\r
   EFI_STATUS        Status;\r
@@ -960,7 +946,7 @@ IpIoStop (
   }\r
 \r
   //\r
-  // All pending snd tokens should be flushed by reseting the IP instances.\r
+  // All pending send tokens should be flushed by reseting the IP instances.\r
   //\r
   ASSERT (IsListEmpty (&IpIo->PendingSndList));\r
 \r
@@ -975,17 +961,21 @@ IpIoStop (
 \r
 /**\r
   Destroy an IP_IO instance.\r
+  \r
+  This function is paired with IpIoCreate(). The IP_IO will be closed first.\r
+  Resource will be freed afterwards. See IpIoCloseProtocolDestroyIpChild().\r
 \r
-  @param  IpIo                  Pointer to the IP_IO instance that needs to\r
-                                destroy.\r
+  @param[in, out]  IpIo         Pointer to the IP_IO instance that needs to be\r
+                                destroyed.\r
 \r
-  @retval EFI_SUCCESS           The IP_IO instance destroyed successfully.\r
-  @retval other                 Error condition occurred.\r
+  @retval          EFI_SUCCESS  The IP_IO instance destroyed successfully.\r
+  @retval          Others       Error condition occurred.\r
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 IpIoDestroy (\r
-  IN IP_IO *IpIo\r
+  IN OUT IP_IO *IpIo\r
   )\r
 {\r
   //\r
@@ -1006,30 +996,37 @@ IpIoDestroy (
 \r
 /**\r
   Send out an IP packet.\r
-\r
-  @param  IpIo                  Pointer to an IP_IO instance used for sending IP\r
-                                packet.\r
-  @param  Pkt                   Pointer to the IP packet to be sent.\r
-  @param  Sender                The IP protocol instance used for sending.\r
-  @param  NotifyData\r
-  @param  Dest                  The destination IP address to send this packet to.\r
-  @param  OverrideData          The data to override some configuration of the IP\r
-                                instance used for sending.\r
-\r
-  @retval EFI_SUCCESS           The operation is completed successfully.\r
-  @retval EFI_NOT_STARTED       The IpIo is not configured.\r
-  @retval EFI_OUT_OF_RESOURCES  Failed due to resource limit.\r
+  \r
+  This function is called after IpIoOpen(). The data to be sent are wrapped in\r
+  Pkt. The IP instance wrapped in IpIo is used for sending by default but can be\r
+  overriden by Sender. Other sending configs, like source address and gateway\r
+  address etc., are specified in OverrideData.\r
+\r
+  @param[in, out]  IpIo                  Pointer to an IP_IO instance used for sending IP\r
+                                         packet.\r
+  @param[in, out]  Pkt                   Pointer to the IP packet to be sent.\r
+  @param[in]       Sender                The IP protocol instance used for sending.\r
+  @param[in]       Context               Optional context data.\r
+  @param[in]       NotifyData            Optional notify data.\r
+  @param[in]       Dest                  The destination IP address to send this packet to.\r
+  @param[in]       OverrideData          The data to override some configuration of the IP\r
+                                         instance used for sending.\r
+\r
+  @retval          EFI_SUCCESS           The operation is completed successfully.\r
+  @retval          EFI_NOT_STARTED       The IpIo is not configured.\r
+  @retval          EFI_OUT_OF_RESOURCES  Failed due to resource limit.\r
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 IpIoSend (\r
-  IN IP_IO           *IpIo,\r
-  IN NET_BUF         *Pkt,\r
-  IN IP_IO_IP_INFO   *Sender,\r
-  IN VOID            *Context    OPTIONAL,\r
-  IN VOID            *NotifyData OPTIONAL,\r
-  IN IP4_ADDR        Dest,\r
-  IN IP_IO_OVERRIDE  *OverrideData\r
+  IN OUT IP_IO          *IpIo,\r
+  IN OUT NET_BUF        *Pkt,\r
+  IN     IP_IO_IP_INFO  *Sender        OPTIONAL,\r
+  IN     VOID           *Context       OPTIONAL,\r
+  IN     VOID           *NotifyData    OPTIONAL,\r
+  IN     IP4_ADDR       Dest,\r
+  IN     IP_IO_OVERRIDE *OverrideData  OPTIONAL\r
   )\r
 {\r
   EFI_STATUS        Status;\r
@@ -1065,13 +1062,12 @@ IpIoSend (
 /**\r
   Cancel the IP transmit token which wraps this Packet.\r
 \r
-  @param  IpIo                  Pointer to the IP_IO instance.\r
-  @param  Packet                Pointer to the packet to cancel.\r
-\r
-  @return N/A.\r
+  @param[in]  IpIo                  Pointer to the IP_IO instance.\r
+  @param[in]  Packet                Pointer to the packet of NET_BUF to cancel.\r
 \r
 **/\r
 VOID\r
+EFIAPI\r
 IpIoCancelTxToken (\r
   IN IP_IO  *IpIo,\r
   IN VOID   *Packet\r
@@ -1081,7 +1077,7 @@ IpIoCancelTxToken (
   IP_IO_SEND_ENTRY  *SndEntry;\r
   EFI_IP4_PROTOCOL  *Ip;\r
 \r
-  ASSERT (IpIo && Packet);\r
+  ASSERT ((IpIo)!= NULL && (Packet)!= NULL);\r
 \r
   NET_LIST_FOR_EACH (Node, &IpIo->PendingSndList) {\r
 \r
@@ -1101,22 +1097,27 @@ IpIoCancelTxToken (
 \r
 /**\r
   Add a new IP instance for sending data.\r
+  \r
+  The function is used to add the IP_IO to the IP_IO sending list. The caller\r
+  can later use IpIoFindSender() to get the IP_IO and call IpIoSend() to send\r
+  data.\r
 \r
-  @param  IpIo                  Pointer to a IP_IO instance to add a new IP\r
-                                instance for sending purpose.\r
+  @param[in, out]  IpIo               Pointer to a IP_IO instance to add a new IP\r
+                                      instance for sending purpose.\r
 \r
-  @return Pointer to the created IP_IO_IP_INFO structure, NULL is failed.\r
+  @return Pointer to the created IP_IO_IP_INFO structure, NULL if failed.\r
 \r
 **/\r
 IP_IO_IP_INFO *\r
+EFIAPI\r
 IpIoAddIp (\r
-  IN IP_IO  *IpIo\r
+  IN OUT IP_IO  *IpIo\r
   )\r
 {\r
   EFI_STATUS     Status;\r
   IP_IO_IP_INFO  *IpInfo;\r
 \r
-  ASSERT (IpIo);\r
+  ASSERT (IpIo != NULL);\r
 \r
   IpInfo = AllocatePool (sizeof (IP_IO_IP_INFO));\r
   if (IpInfo == NULL) {\r
@@ -1187,20 +1188,22 @@ ReleaseIpInfo:
   Configure the IP instance of this IpInfo and start the receiving if Ip4ConfigData\r
   is not NULL.\r
 \r
-  @param  IpInfo                Pointer to the IP_IO_IP_INFO instance.\r
-  @param  Ip4ConfigData         The IP4 configure data used to configure the ip\r
-                                instance, if NULL the ip instance is reseted. If\r
-                                UseDefaultAddress is set to TRUE, and the configure\r
-                                operation succeeds, the default address information\r
-                                is written back in this Ip4ConfigData.\r
+  @param[in, out]  IpInfo          Pointer to the IP_IO_IP_INFO instance.\r
+  @param[in, out]  Ip4ConfigData   The IP4 configure data used to configure the IP\r
+                                   instance, if NULL the IP instance is reset. If\r
+                                   UseDefaultAddress is set to TRUE, and the configure\r
+                                   operation succeeds, the default address information\r
+                                   is written back in this Ip4ConfigData.\r
 \r
-  @retval EFI_STATUS            The status returned by IP4->Configure or\r
-                                IP4->Receive.\r
+  @retval          EFI_SUCCESS     The IP instance of this IpInfo is configured successfully\r
+                                   or no need to reconfigure it.\r
+  @retval          Others          Configuration fails.\r
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 IpIoConfigIp (\r
-  IN     IP_IO_IP_INFO        *IpInfo,\r
+  IN OUT IP_IO_IP_INFO        *IpInfo,\r
   IN OUT EFI_IP4_CONFIG_DATA  *Ip4ConfigData OPTIONAL\r
   )\r
 {\r
@@ -1208,7 +1211,7 @@ IpIoConfigIp (
   EFI_IP4_PROTOCOL   *Ip;\r
   EFI_IP4_MODE_DATA  Ip4ModeData;\r
 \r
-  ASSERT (IpInfo);\r
+  ASSERT (IpInfo != NULL);\r
 \r
   if (IpInfo->RefCnt > 1) {\r
     //\r
@@ -1261,17 +1264,20 @@ OnExit:
 /**\r
   Destroy an IP instance maintained in IpIo->IpList for\r
   sending purpose.\r
+  \r
+  This function pairs with IpIoAddIp(). The IpInfo is previously created by\r
+  IpIoAddIp(). The IP_IO_IP_INFO::RefCnt is decremented and the IP instance\r
+  will be dstroyed if the RefCnt is zero.\r
 \r
-  @param  IpIo                  Pointer to the IP_IO instance.\r
-  @param  IpInfo                Pointer to the IpInfo to be removed.\r
-\r
-  @return None.\r
+  @param[in]  IpIo                  Pointer to the IP_IO instance.\r
+  @param[in]  IpInfo                Pointer to the IpInfo to be removed.\r
 \r
 **/\r
 VOID\r
+EFIAPI\r
 IpIoRemoveIp (\r
-  IN IP_IO          *IpIo,\r
-  IN IP_IO_IP_INFO  *IpInfo\r
+  IN IP_IO            *IpIo,\r
+  IN IP_IO_IP_INFO    *IpInfo\r
   )\r
 {\r
   ASSERT (IpInfo->RefCnt > 0);\r
@@ -1298,15 +1304,19 @@ IpIoRemoveIp (
 /**\r
   Find the first IP protocol maintained in IpIo whose local\r
   address is the same with Src.\r
+  \r
+  This function is called when the caller needs the IpIo to send data to the\r
+  specified Src. The IpIo was added previously by IpIoAddIp().\r
 \r
-  @param  IpIo                  Pointer to the pointer of the IP_IO instance.\r
-  @param  Src                   The local IP address.\r
+  @param[in, out]  IpIo              Pointer to the pointer of the IP_IO instance.\r
+  @param[in]       Src               The local IP address.\r
 \r
   @return Pointer to the IP protocol can be used for sending purpose and its local\r
   @return address is the same with Src.\r
 \r
 **/\r
 IP_IO_IP_INFO *\r
+EFIAPI\r
 IpIoFindSender (\r
   IN OUT IP_IO     **IpIo,\r
   IN     IP4_ADDR  Src\r
@@ -1342,23 +1352,24 @@ IpIoFindSender (
 \r
 \r
 /**\r
-  Get the ICMP error map information, the ErrorStatus will be returned.\r
-  The IsHard and Notify are optional. If they are not NULL, this rouine will\r
-  fill them.\r
-  We move IcmpErrMap[] to local variable to enable EBC build.\r
+  Get the ICMP error map information.\r
+  \r
+  The ErrorStatus will be returned. The IsHard and Notify are optional. If they\r
+  are not NULL, this routine will fill them.\r
 \r
-  @param  IcmpError             IcmpError Type\r
-  @param  IsHard                Whether it is a hard error\r
-  @param  Notify                Whether it need to notify SockError\r
+  @param[in]   IcmpError             IcmpError Type.\r
+  @param[out]  IsHard                Whether it is a hard error.\r
+  @param[out]  Notify                Whether it need to notify SockError.\r
 \r
-  @return ICMP Error Status\r
+  @return ICMP Error Status, such as EFI_NETWORK_UNREACHABLE.\r
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 IpIoGetIcmpErrStatus (\r
   IN  ICMP_ERROR  IcmpError,\r
-  OUT BOOLEAN     *IsHard, OPTIONAL\r
-  OUT BOOLEAN     *Notify OPTIONAL\r
+  OUT BOOLEAN     *IsHard  OPTIONAL,\r
+  OUT BOOLEAN     *Notify  OPTIONAL\r
   )\r
 {\r
   ASSERT ((IcmpError >= ICMP_ERR_UNREACH_NET) && (IcmpError <= ICMP_ERR_PARAMPROB));\r