]> git.proxmox.com Git - mirror_edk2.git/commitdiff
add macro function comments
authorywu21 <ywu21@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 12 Jan 2009 02:39:41 +0000 (02:39 +0000)
committerywu21 <ywu21@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 12 Jan 2009 02:39:41 +0000 (02:39 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7242 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Include/Library/IpIoLib.h

index 1f983c9be214c8d4e5eb72c3964ff6a79013b257..99b98d8075d872d3e513ce0b65d7349a1452c36a 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   This library provides IpIo layer upon EFI IP4 Protocol.\r
 \r
-Copyright (c) 2005 - 2008, Intel Corporation\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
@@ -16,7 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define _IP_IO_H_\r
 \r
 #include <Protocol/Ip4.h>\r
-#include <Library/IpIoLib.h>\r
+\r
 #include <Library/NetLib.h>\r
 \r
 //\r
@@ -24,7 +24,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 // 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
@@ -42,6 +42,42 @@ 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
+  Get the IP header length from EFI_IP4_HEADER struct. 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
@@ -63,22 +99,11 @@ typedef enum {
 ///\r
 /// The helper struct for IpIoGetIcmpErrStatus(). It is internal-use only.\r
 ///\r
-typedef struct _ICMP_ERROR_INFO {\r
+typedef struct {\r
   BOOLEAN     IsHard;\r
   BOOLEAN     Notify;\r
 } ICMP_ERROR_INFO;\r
 \r
-/**\r
-  Get the IP header length from EFI_IP4_HEADER struct.\r
-  \r
-  @param 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
-extern EFI_IP4_CONFIG_DATA  mIpIoDefaultIpConfigData;\r
-\r
 ///\r
 /// The IP session for an IP receive packet.\r
 ///\r
@@ -91,12 +116,12 @@ typedef struct _EFI_NET_SESSION_DATA {
 /**\r
   The prototype is called back when an IP packet is received.\r
   \r
-  @param Status        Result of the receive request\r
-  @param IcmpErr       Valid when Status is EFI_ICMP_ERROR\r
-  @param NetSession    The IP session for the received packet\r
-  @param Pkt           Packet received\r
-  @param Context       The data provided by user for the received packet when\r
-                       the callback is registered in IP_IO_OPEN_DATA::RcvdContext.\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 user for the received packet when\r
+                           the callback is registered in IP_IO_OPEN_DATA::RcvdContext.\r
   \r
 **/\r
 typedef\r
@@ -112,11 +137,11 @@ VOID
 /**\r
   The prototype is called back when an IP packet is sent.\r
   \r
-  @param Status        Result of the sending\r
-  @param Context       The data provided by user for the received packet when\r
-                       the callback is registered in IP_IO_OPEN_DATA::SndContext.\r
-  @param Sender        A pointer to EFI_IP4_PROTOCOL for sender\r
-  @param NotifyData    Context data specified when calling IpIoSend()\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
@@ -153,7 +178,7 @@ typedef struct _IP_IO {
   BOOLEAN                       IsConfigured;\r
 \r
   ///\r
-  /// some ip config data can be changed\r
+  /// Some ip config data can be changed\r
   ///\r
   UINT8                         Protocol;\r
 \r
@@ -226,9 +251,9 @@ typedef struct _IP_IO_IP_INFO {
   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 the driver or application that\r
+  @param[in]  Image             The image handle of the driver or application that\r
                                 consumes IP_IO.\r
-  @param  Controller            The controller handle that has IP4 service binding\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, or NULL if failed.\r
@@ -247,17 +272,17 @@ IpIoCreate (
   This function is paired with IpIoCreate(). The IP_IO will be closed first.\r
   Resource will be freed afterwards. See IpIoClose().\r
 \r
-  @param  IpIo                  Pointer to the IP_IO instance that needs to be\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
@@ -266,16 +291,16 @@ IpIoDestroy (
   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
 /**\r
@@ -285,20 +310,23 @@ IpIoStop (
   instance and register the callbacks and their context data for sending and\r
   receiving IP packets.\r
 \r
-  @param  IpIo                  Pointer to an IP_IO instance that needs to open.\r
-  @param  OpenData              The configuration data and callbacks for the IP_IO\r
-                                instance.\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 Other                 Error condition occurred.\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
 /**\r
@@ -309,38 +337,38 @@ IpIoOpen (
   overriden by Sender. Other sending configs, like source address and gateway\r
   address etc., are specified in OverrideData.\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  Context               Optional context data\r
-  @param  NotifyData            Optional notify data\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
+  @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
+  @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        OPTIONAL,\r
-  IN VOID            *Context       OPTIONAL,\r
-  IN VOID            *NotifyData    OPTIONAL,\r
-  IN IP4_ADDR        Dest,\r
-  IN IP_IO_OVERRIDE  *OverrideData  OPTIONAL\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
 /**\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 of NET_BUF to cancel.\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
@@ -357,8 +385,8 @@ IpIoCancelTxToken (
   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 if failed.\r
 \r
@@ -366,29 +394,29 @@ IpIoCancelTxToken (
 IP_IO_IP_INFO *\r
 EFIAPI\r
 IpIoAddIp (\r
-  IN IP_IO  *IpIo\r
+  IN OUT IP_IO  *IpIo\r
   );\r
 \r
 /**\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 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
+  @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 Other                 Configuration fails.\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
@@ -400,8 +428,8 @@ IpIoConfigIp (
   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
 **/\r
 VOID\r
@@ -418,8 +446,8 @@ IpIoRemoveIp (
   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
           address is the same with Src.\r
@@ -438,11 +466,11 @@ IpIoFindSender (
   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