]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Include/Library/IpIoLib.h
Committing changes to the comments, to improve code documentation.
[mirror_edk2.git] / MdeModulePkg / Include / Library / IpIoLib.h
index acee69f22939996e12a2a761b27de40cb3258012..daf8c308a1076ff55cef95c1748e844888702313 100644 (file)
@@ -1,31 +1,31 @@
-/** @file
-  This library provides IpIo layer upon EFI IP4 Protocol.\r
-
-Copyright (c) 2005 - 2008, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution.  The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef _IP_IO_H_
-#define _IP_IO_H_
-
-#include <PiDxe.h>
+/** @file\r
+  Ihis library is only intended to be used by UEFI network stack modules.\r
+  It provides the IpIo layer on the EFI IP4 Protocol.\r
+\r
+Copyright (c) 2005 - 2008, 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
+http://opensource.org/licenses/bsd-license.php\r
+\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
+**/\r
+\r
+#ifndef _IP_IO_H_\r
+#define _IP_IO_H_\r
+\r
 #include <Protocol/Ip4.h>\r
-#include <Library/IpIoLib.h>\r
-#include <Library/NetLib.h>
-
+\r
+#include <Library/NetLib.h>\r
+\r
 //\r
-// type and code define for ICMP protocol error got\r
+// type and code define for ICMP protocol error \r
 // from IP\r
 //\r
 #define ICMP_TYPE_UNREACH              3\r
-#define ICMP_TYPE_TIMXCEED            11\r
+#define ICMP_TYPE_TIMXCEED             11\r
 #define ICMP_TYPE_PARAMPROB            12\r
 #define ICMP_TYPE_SOURCEQUENCH         4\r
 \r
@@ -43,11 +43,47 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define ICMP_CODE_UNREACH_TOSNET       11\r
 #define ICMP_CODE_UNREACH_TOSHOST      12\r
 \r
-//\r
-// this error will be delivered to the\r
-// listening transportation layer protocol\r
-// consuming IpIO\r
-//\r
+/**\r
+  Get the IP header length from the struct EFI_IP4_HEADER. HeaderLength is\r
+  Internet header length in 32-bit words, so HeaderLength<<2 is the real\r
+  length of IP header.\r
+  \r
+  @param[out] HdrPtr   A pointer to EFI_IP4_HEADER\r
+  \r
+  @return The IP header length\r
+**/\r
+#define EFI_IP4_HEADER_LEN(HdrPtr) ((HdrPtr)->HeaderLength << 2)\r
+\r
+/**\r
+  To types of ICMP error which consist of ICMP header, IP header and original \r
+  datagram's data, get length from sum of ICMP header length, IP header length \r
+  and first 64 bits of datagram's data length.\r
+  \r
+  @param[in] IpHdr   A pointer to EFI_IP4_HEADER\r
+  \r
+  @return The ICMP error length\r
+**/\r
+#define ICMP_ERRLEN(IpHdr) \\r
+  (sizeof(IP4_ICMP_HEAD) + EFI_IP4_HEADER_LEN(IpHdr) + 8)\r
+\r
+/**\r
+  Get the packet header from NET_BUF.\r
+  \r
+  @param[out]  Buf    A pointer to NET_BUF\r
+  @param[in]   Type   Header type\r
+  \r
+  @return The pointer to packet header\r
+**/\r
+#define NET_PROTO_HDR(Buf, Type)  ((Type *) ((Buf)->BlockOp[0].Head))\r
+\r
+  \r
+extern EFI_IP4_CONFIG_DATA  mIpIoDefaultIpConfigData;\r
+\r
+///\r
+/// This error will be delivered to the\r
+/// listening transportation layer protocol\r
+/// that consumes IpIO.\r
+///\r
 typedef enum {\r
   ICMP_ERR_UNREACH_NET      = 0,\r
   ICMP_ERR_UNREACH_HOST,\r
@@ -61,316 +97,389 @@ typedef enum {
   ICMP_ERR_PARAMPROB\r
 } ICMP_ERROR;\r
 \r
-typedef struct _ICMP_ERROR_INFO {\r
+///\r
+/// The helper struct for IpIoGetIcmpErrStatus(). It is for internal use only.\r
+///\r
+typedef struct {\r
   BOOLEAN     IsHard;\r
   BOOLEAN     Notify;\r
 } ICMP_ERROR_INFO;\r
-
-#define EFI_IP4_HEADER_LEN(HdrPtr) ((HdrPtr)->HeaderLength << 2)
-
-extern EFI_IP4_CONFIG_DATA  mIpIoDefaultIpConfigData;
-
-typedef struct _EFI_NET_SESSION_DATA {
-  IP4_ADDR        Source;
-  IP4_ADDR        Dest;
-  EFI_IP4_HEADER  *IpHdr;
-} EFI_NET_SESSION_DATA;
-
-typedef
-VOID
-(*PKT_RCVD_NOTIFY) (
-  IN EFI_STATUS           Status,  // rcvd pkt result
-  IN ICMP_ERROR           IcmpErr, // if Status == EFI_ICMP_ERROR, this
-                                  // field is valid for user
-  IN EFI_NET_SESSION_DATA *NetSession, // the communication point
-  IN NET_BUF              *Pkt,    // packet received
-  IN VOID                 *Context // the Context provided by user for recive data
-  );
-
-typedef
-VOID
-(*PKT_SENT_NOTIFY) (
-  IN EFI_STATUS  Status,      // sent pkt result
-  IN VOID        *Context,    // the context provided by user for sending data
-  IN VOID        *Sender,     // the sender to be notified
-  IN VOID        *NotifyData  // sent pkt related data to notify
-  );
-
-typedef struct _IP_IO {
-
-  //
-  // the node used to link this IpIo to the active IpIo list.
-  //
-  LIST_ENTRY                    Entry;
-
-  // the list used to maintain the IP instance for different sending purpose.
-  //
-  LIST_ENTRY                    IpList;
-
-  //
-  // the ip instance consumed by this IP IO
-  //
-  EFI_HANDLE                    Controller;
-  EFI_HANDLE                    Image;
-  EFI_HANDLE                    ChildHandle;
-  EFI_IP4_PROTOCOL              *Ip;
-  BOOLEAN                       IsConfigured;
-
-  //
-  // some ip config data can be changed
-  //
-  UINT8                         Protocol;
-
-  //
-  // token and event used to get data from IP
-  //
-  EFI_IP4_COMPLETION_TOKEN      RcvToken;
-
-  //
-  // list entry used to link the token passed to IP_IO
-  //
-  LIST_ENTRY                    PendingSndList;
-
-  //
-  // User interface used to get notify from IP_IO
-  //
-  VOID                          *RcvdContext;
-  VOID                          *SndContext;
-  PKT_RCVD_NOTIFY               PktRcvdNotify;
-  PKT_SENT_NOTIFY               PktSentNotify;
-} IP_IO;
-
-typedef struct _IP_IO_OPEN_DATA {
-  EFI_IP4_CONFIG_DATA IpConfigData;
-  VOID                *RcvdContext;
-  VOID                *SndContext;
-  PKT_RCVD_NOTIFY     PktRcvdNotify;
-  PKT_SENT_NOTIFY     PktSentNotify;
-} IP_IO_OPEN_DATA;
-
-typedef struct _IP_IO_SEND_ENTRY {
-  LIST_ENTRY                Entry;
-  IP_IO                     *IpIo;
-  VOID                      *Context;
-  VOID                      *NotifyData;
-  EFI_IP4_PROTOCOL          *Ip;
-  NET_BUF                   *Pkt;
-  EFI_IP4_COMPLETION_TOKEN  *SndToken;
-} IP_IO_SEND_ENTRY;
-
-typedef EFI_IP4_OVERRIDE_DATA IP_IO_OVERRIDE;
-
-typedef struct _IP_IO_IP_INFO {
-  IP4_ADDR                  Addr;
-  IP4_ADDR                  SubnetMask;
-  LIST_ENTRY                Entry;
-  EFI_HANDLE                ChildHandle;
-  EFI_IP4_PROTOCOL          *Ip;
-  EFI_IP4_COMPLETION_TOKEN  DummyRcvToken;
-  INTN                      RefCnt;
-} IP_IO_IP_INFO;
-
+\r
+///\r
+/// The IP session for an IP receive packet.\r
+///\r
+typedef struct _EFI_NET_SESSION_DATA {\r
+  IP4_ADDR        Source;     ///< Source IP of the received packet\r
+  IP4_ADDR        Dest;       ///< Destination IP of the received packet\r
+  EFI_IP4_HEADER  *IpHdr;     ///< IP4 header of the received packet\r
+} EFI_NET_SESSION_DATA;\r
+\r
+/**\r
+  The prototype is called back when an IP packet is received.\r
+  \r
+  @param[in] Status        Result of the receive request\r
+  @param[in] IcmpErr       Valid when Status is EFI_ICMP_ERROR\r
+  @param[in] NetSession    The IP session for the received packet\r
+  @param[in] Pkt           Packet received\r
+  @param[in] Context       The data provided by the user for the received packet when\r
+                           the callback is registered in IP_IO_OPEN_DATA::RcvdContext.\r
+  \r
+**/\r
+typedef\r
+VOID\r
+(*PKT_RCVD_NOTIFY) (\r
+  IN EFI_STATUS           Status, \r
+  IN ICMP_ERROR           IcmpErr,\r
+  IN EFI_NET_SESSION_DATA *NetSession,\r
+  IN NET_BUF              *Pkt,\r
+  IN VOID                 *Context\r
+  );\r
+\r
+/**\r
+  The prototype is called back when an IP packet is sent.\r
+  \r
+  @param[in] Status        Result of the sending\r
+  @param[in] Context       The data provided by user for the received packet when\r
+                           the callback is registered in IP_IO_OPEN_DATA::SndContext.\r
+  @param[in] Sender        A pointer to EFI_IP4_PROTOCOL for sender\r
+  @param[in] NotifyData    Context data specified when calling IpIoSend()\r
+  \r
+**/\r
+typedef\r
+VOID\r
+(*PKT_SENT_NOTIFY) (\r
+  IN EFI_STATUS  Status,\r
+  IN VOID        *Context,\r
+  IN VOID        *Sender,\r
+  IN VOID        *NotifyData\r
+  );\r
+\r
+///\r
+/// This data structure wraps Ip4 instances. The IpIo Library uses it for all\r
+/// Ip4 operations.\r
+///\r
+typedef struct _IP_IO {\r
+  ///\r
+  /// The node used to link this IpIo to the active IpIo list.\r
+  ///\r
+  LIST_ENTRY                    Entry;\r
+\r
+  ///\r
+  /// The list used to maintain the IP instance for different sending purpose.\r
+  ///\r
+  LIST_ENTRY                    IpList;\r
+  \r
+  EFI_HANDLE                    Controller;\r
+  EFI_HANDLE                    Image;\r
+  EFI_HANDLE                    ChildHandle;\r
+  //\r
+  // The IP instance consumed by this IP_IO\r
+  //\r
+  EFI_IP4_PROTOCOL              *Ip;\r
+  BOOLEAN                       IsConfigured;\r
+\r
+  ///\r
+  /// Some ip config data can be changed\r
+  ///\r
+  UINT8                         Protocol;\r
+\r
+  ///\r
+  /// Token and event used to get data from IP\r
+  ///\r
+  EFI_IP4_COMPLETION_TOKEN      RcvToken;\r
+\r
+  ///\r
+  /// List entry used to link the token passed to IP_IO\r
+  ///\r
+  LIST_ENTRY                    PendingSndList;\r
+\r
+  //\r
+  // User interface used to get notify from IP_IO\r
+  //\r
+  VOID                          *RcvdContext;    ///< See IP_IO_OPEN_DATA::RcvdContext\r
+  VOID                          *SndContext;     ///< See IP_IO_OPEN_DATA::SndContext\r
+  PKT_RCVD_NOTIFY               PktRcvdNotify;   ///< See IP_IO_OPEN_DATA::PktRcvdNotify\r
+  PKT_SENT_NOTIFY               PktSentNotify;   ///< See IP_IO_OPEN_DATA::PktSentNotify\r
+} IP_IO;\r
+\r
+///\r
+/// The struct is for the user to pass IP configuration and callbacks to IP_IO.\r
+/// It is used by IpIoOpen().\r
+///\r
+typedef struct _IP_IO_OPEN_DATA {\r
+  EFI_IP4_CONFIG_DATA IpConfigData;    ///< Configuration of the IP instance\r
+  VOID                *RcvdContext;    ///< Context data used by receive callback\r
+  VOID                *SndContext;     ///< Context data used by send callback\r
+  PKT_RCVD_NOTIFY     PktRcvdNotify;   ///< Receive callback\r
+  PKT_SENT_NOTIFY     PktSentNotify;   ///< Send callback\r
+} IP_IO_OPEN_DATA;\r
+\r
+///\r
+/// Internal struct book-keeping send request of IP_IO.\r
+///\r
+/// An IP_IO_SEND_ENTRY will be created each time a send request is issued to\r
+/// IP_IO via IpIoSend().\r
+///\r
+typedef struct _IP_IO_SEND_ENTRY {\r
+  LIST_ENTRY                Entry;\r
+  IP_IO                     *IpIo;\r
+  VOID                      *Context;\r
+  VOID                      *NotifyData;\r
+  EFI_IP4_PROTOCOL          *Ip;\r
+  NET_BUF                   *Pkt;\r
+  EFI_IP4_COMPLETION_TOKEN  *SndToken;\r
+} IP_IO_SEND_ENTRY;\r
+\r
+typedef EFI_IP4_OVERRIDE_DATA IP_IO_OVERRIDE;\r
+\r
+///\r
+/// The IP_IO_IP_INFO is used in IpIoSend() to override the default IP instance\r
+/// in IP_IO.\r
+///\r
+typedef struct _IP_IO_IP_INFO {\r
+  IP4_ADDR                  Addr;\r
+  IP4_ADDR                  SubnetMask;\r
+  LIST_ENTRY                Entry;\r
+  EFI_HANDLE                ChildHandle;\r
+  EFI_IP4_PROTOCOL          *Ip;\r
+  EFI_IP4_COMPLETION_TOKEN  DummyRcvToken;\r
+  INTN                      RefCnt;\r
+} IP_IO_IP_INFO;\r
+\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
+  );\r
 \r
-**/
-IP_IO *
-EFIAPI
-IpIoCreate (
-  IN EFI_HANDLE Image,
-  IN EFI_HANDLE Controller
-  );
-
 /**\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 IpIoClose().\r
+\r
+  @param[in, out]  IpIo         Pointer to the IP_IO instance that needs to be\r
+                                destroyed.\r
 \r
-  @param  IpIo                  Pointer to the IP_IO instance that needs to\r
-                                destroy.\r
+  @retval          EFI_SUCCESS  The IP_IO instance destroyed successfully.\r
+  @retval          Others       Error condition occurred.\r
 \r
-  @retval EFI_SUCCESS           The IP_IO instance destroyed successfully.\r
-  @retval other                 Error condition occurred.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+IpIoDestroy (\r
+  IN OUT IP_IO *IpIo\r
+  );\r
 \r
-**/
-EFI_STATUS
-EFIAPI
-IpIoDestroy (
-  IN IP_IO *IpIo
-  );
-
 /**\r
   Stop an IP_IO instance.\r
+  \r
+  This function is paired with IpIoOpen(). The IP_IO will be unconfigured, and all\r
+  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 OUT IP_IO *IpIo\r
+  );\r
 \r
-**/
-EFI_STATUS
-EFIAPI
-IpIoStop (
-  IN IP_IO *IpIo
-  );
-
 /**\r
   Open an IP_IO instance for use.\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
-  @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
+EFI_STATUS\r
+EFIAPI\r
+IpIoOpen (\r
+  IN OUT IP_IO           *IpIo,\r
+  IN     IP_IO_OPEN_DATA *OpenData\r
+  );\r
 \r
-**/
-EFI_STATUS
-IpIoOpen (
-  IN IP_IO           *IpIo,
-  IN IP_IO_OPEN_DATA *OpenData
-  );
-
 /**\r
   Send out an IP packet.\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 configurations, such as source address and gateway\r
+  address, 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                Optional. 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 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
-  @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
-**/
-EFI_STATUS
-EFIAPI
-IpIoSend (
-  IN IP_IO           *IpIo,
-  IN NET_BUF         *Pkt,
-  IN IP_IO_IP_INFO   *Sender,
-  IN VOID            *Context    OPTIONAL,
-  IN VOID            *NotifyData OPTIONAL,
-  IN IP4_ADDR        Dest,
-  IN IP_IO_OVERRIDE  *OverrideData
-  );
-
 /**\r
-  Add a new IP instance for sending data.\r
+  Cancel the IP transmit token which wraps this Packet.\r
 \r
-  @param  IpIo                  Pointer to a IP_IO instance to add a new IP\r
-                                instance for sending purpose.\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
-  @return Pointer to the created IP_IO_IP_INFO structure, NULL is failed.\r
+**/\r
+VOID\r
+EFIAPI\r
+IpIoCancelTxToken (\r
+  IN IP_IO  *IpIo,\r
+  IN VOID   *Packet\r
+  );\r
 \r
-**/
-VOID
-EFIAPI
-IpIoCancelTxToken (
-  IN IP_IO  *IpIo,
-  IN VOID   *Packet
-  );
-
 /**\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[in, out]  IpIo               Pointer to an IP_IO instance to add a new IP\r
+                                      instance for sending purposes.\r
 \r
-  @param  IpIo                  Pointer to a IP_IO instance to add a new IP\r
-                                instance for sending purpose.\r
+  @return Pointer to the created IP_IO_IP_INFO structure, NULL if failed.\r
 \r
-  @return Pointer to the created IP_IO_IP_INFO structure, NULL is failed.\r
+**/\r
+IP_IO_IP_INFO *\r
+EFIAPI\r
+IpIoAddIp (\r
+  IN OUT IP_IO  *IpIo\r
+  );\r
 \r
-**/
-IP_IO_IP_INFO *
-EFIAPI
-IpIoAddIp (
-  IN IP_IO  *IpIo
-  );
-
 /**\r
   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
-\r
-  @retval EFI_STATUS            The status returned by IP4->Configure or\r
-                                IP4->Receive.\r
-\r
-**/
-EFI_STATUS
-EFIAPI
-IpIoConfigIp (
-  IN     IP_IO_IP_INFO        *IpInfo,
-  IN OUT EFI_IP4_CONFIG_DATA  *Ip4ConfigData OPTIONAL
-  );
-
+  @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_SUCCESS     The IP instance of this IpInfo is configured successfully,\r
+                                   or there is no need to reconfigure it.\r
+  @retval          Others          Configuration failed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+IpIoConfigIp (\r
+  IN OUT IP_IO_IP_INFO        *IpInfo,\r
+  IN OUT EFI_IP4_CONFIG_DATA  *Ip4ConfigData OPTIONAL\r
+  );\r
+\r
 /**\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
+  @param[in]  IpIo                  Pointer to the IP_IO instance.\r
+  @param[in]  IpInfo                Pointer to the IpInfo to be removed.\r
 \r
-  @return None.\r
+**/\r
+VOID\r
+EFIAPI\r
+IpIoRemoveIp (\r
+  IN IP_IO            *IpIo,\r
+  IN IP_IO_IP_INFO    *IpInfo\r
+  );\r
 \r
-**/
-VOID
-EFIAPI
-IpIoRemoveIp (
-  IN IP_IO            *IpIo,
-  IN IP_IO_IP_INFO    *IpInfo
-  );
-
 /**\r
   Find the first IP protocol maintained in IpIo whose local\r
-  address is the same with Src.\r
+  address is the same as 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
-**/
-IP_IO_IP_INFO *
-EFIAPI
-IpIoFindSender (
-  IN OUT IP_IO     **IpIo,
-  IN     IP4_ADDR  Src
-  );
-
+          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
+  );\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
-EFIAPI
-IpIoGetIcmpErrStatus (
-  IN  ICMP_ERROR  IcmpError,
-  OUT BOOLEAN     *IsHard, OPTIONAL
-  OUT BOOLEAN     *Notify OPTIONAL
-  );
-
-#endif
+EFI_STATUS\r
+EFIAPI\r
+IpIoGetIcmpErrStatus (\r
+  IN  ICMP_ERROR  IcmpError,\r
+  OUT BOOLEAN     *IsHard  OPTIONAL,\r
+  OUT BOOLEAN     *Notify  OPTIONAL\r
+  );\r
+\r
+#endif\r