]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Include/Library/NetLib.h
Committing changes to the comments, to improve code documentation.
[mirror_edk2.git] / MdeModulePkg / Include / Library / NetLib.h
index b057cbd2cee4b4f74b9e05548d17bb146cc9b085..c1519fea23e8f1d6c55c63151fd5fe615e55d7c0 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
   Ihis library is only intended to be used by UEFI network stack modules.\r
-  It provides basic function for UEFI network stack.\r
+  It provides basic functions for the UEFI network stack.\r
 \r
 Copyright (c) 2005 - 2008, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
@@ -76,7 +76,7 @@ typedef struct {
 \r
 \r
 //\r
-// ICMP head definition. ICMP message is categoried as either an error\r
+// ICMP head definition. Each ICMP message is categorized as either an error\r
 // message or query message. Two message types have their own head format.\r
 //\r
 typedef struct {\r
@@ -163,13 +163,13 @@ typedef struct {
 /**\r
   Return the length of the mask. \r
   \r
-  Return the length of the mask, the correct value is from 0 to 32.\r
+  Return the length of the mask. Valid values are 0 to 32.\r
   If the mask is invalid, return the invalid length 33, which is IP4_MASK_NUM.\r
   NetMask is in the host byte order.\r
 \r
   @param[in]  NetMask              The netmask to get the length from.\r
 \r
-  @return The length of the netmask, IP4_MASK_NUM if the mask is invalid.\r
+  @return The length of the netmask, or IP4_MASK_NUM (33) if the mask is invalid.\r
   \r
 **/\r
 INTN\r
@@ -211,13 +211,13 @@ NetGetIpClass (
   \r
   If Ip is 0, IP is not a valid unicast address.\r
   Class D address is used for multicasting and class E address is reserved for future. If Ip\r
-  belongs to class D or class E, IP is not a valid unicast address. \r
-  If all bits of the host address of IP are 0 or 1, IP is also not a valid unicast address.\r
+  belongs to class D or class E, Ip is not a valid unicast address. \r
+  If all bits of the host address of Ip are 0 or 1, Ip is not a valid unicast address.\r
 \r
   @param[in]  Ip                    The IP to check against.\r
   @param[in]  NetMask               The mask of the IP.\r
 \r
-  @return TRUE if IP is a valid unicast address on the network, otherwise FALSE.\r
+  @return TRUE if Ip is a valid unicast address on the network, otherwise FALSE.\r
 \r
 **/\r
 BOOLEAN\r
@@ -245,7 +245,7 @@ extern EFI_IPv4_ADDRESS  mZeroIp4Addr;
 /**\r
   Extract a UINT32 from a byte stream.\r
   \r
-  Copy a UINT32 from a byte stream, then converts it from Network \r
+  This function copies a UINT32 from a byte stream, and then converts it from Network \r
   byte order to host byte order. Use this function to avoid alignment error.\r
 \r
   @param[in]  Buf                 The buffer to extract the UINT32.\r
@@ -260,9 +260,9 @@ NetGetUint32 (
   );\r
 \r
 /**\r
-  Put a UINT32 to the byte stream in network byte order. \r
+  Puts a UINT32 into the byte stream in network byte order. \r
   \r
-  Converts a UINT32 from host byte order to network byte order. Then copy it to the \r
+  Converts a UINT32 from host byte order to network byte order, and then copies it to the \r
   byte stream.\r
 \r
   @param[in, out]  Buf          The buffer to put the UINT32.\r
@@ -280,10 +280,10 @@ NetPutUint32 (
   Initialize a random seed using current time.\r
   \r
   Get current time first. Then initialize a random seed based on some basic \r
-  mathematics operation on the hour, day, minute, second, nanosecond and year \r
+  mathematical operations on the hour, day, minute, second, nanosecond and year \r
   of the current time.\r
   \r
-  @return The random seed initialized with current time.\r
+  @return The random seed, initialized with current time.\r
 \r
 **/\r
 UINT32\r
@@ -300,13 +300,13 @@ NetRandomInitSeed (
           CR(Entry, Type, Field, Sig)\r
 \r
 //\r
-// Iterate through the doule linked list. It is NOT delete safe\r
+// Iterate through the double linked list. It is NOT delete safe\r
 //\r
 #define NET_LIST_FOR_EACH(Entry, ListHead) \\r
   for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)\r
 \r
 //\r
-// Iterate through the doule linked list. This is delete-safe.\r
+// Iterate through the double linked list. This is delete-safe.\r
 // Don't touch NextEntry. Also, don't use this macro if list\r
 // entries other than the Entry may be deleted when processing\r
 // the current Entry.\r
@@ -318,7 +318,7 @@ NetRandomInitSeed (
      )\r
 \r
 //\r
-// Make sure the list isn't empty before get the frist/last record.\r
+// Make sure the list isn't empty before getting the first/last record.\r
 //\r
 #define NET_LIST_HEAD(ListHead, Type, Field)  \\r
           NET_LIST_USER_STRUCT((ListHead)->ForwardLink, Type, Field)\r
@@ -330,8 +330,8 @@ NetRandomInitSeed (
 /**\r
   Remove the first node entry on the list, and return the removed node entry.\r
   \r
-  Removes the first node Entry from a doubly linked list. It is up to the caller of\r
-  this function to release the memory used by the first node if that is required. On\r
+  Removes the first node entry from a doubly linked list. It is up to the caller of\r
+  this function to release the memory used by the first node, if that is required. On\r
   exit, the removed node is returned. \r
 \r
   If Head is NULL, then ASSERT().\r
@@ -352,10 +352,10 @@ NetListRemoveHead (
   );\r
 \r
 /**\r
-  Remove the last node entry on the list and and return the removed node entry.\r
+  Remove the last node entry on the list and return the removed node entry.\r
 \r
   Removes the last node entry from a doubly linked list. It is up to the caller of\r
-  this function to release the memory used by the first node if that is required. On\r
+  this function to release the memory used by the first node, if that is required. On\r
   exit, the removed node is returned. \r
 \r
   If Head is NULL, then ASSERT().\r
@@ -378,10 +378,10 @@ NetListRemoveTail (
 /**\r
   Insert a new node entry after a designated node entry of a doubly linked list.\r
   \r
-  Inserts a new node entry donated by NewEntry after the node entry donated by PrevEntry\r
+  Inserts a new node entry designated by NewEntry after the node entry designated by PrevEntry\r
   of the doubly linked list.\r
  \r
-  @param[in, out]  PrevEntry             The previous entry to insert after.\r
+  @param[in, out]  PrevEntry             The entry after which to insert. \r
   @param[in, out]  NewEntry              The new entry to insert.\r
 \r
 **/\r
@@ -395,7 +395,7 @@ NetListInsertAfter (
 /**\r
   Insert a new node entry before a designated node entry of a doubly linked list.\r
   \r
-  Inserts a new node entry donated by NewEntry after the node entry donated by PostEntry\r
+  Inserts a new node entry designated by NewEntry before the node entry designated by PostEntry\r
   of the doubly linked list.\r
  \r
   @param[in, out]  PostEntry             The entry to insert before.\r
@@ -451,9 +451,9 @@ NetMapInit (
 /**\r
   To clean up the netmap, that is, release allocated memories.\r
   \r
-  Removes all nodes of the Used doubly linked list and free memory of all related netmap items.\r
+  Removes all nodes of the Used doubly linked list and frees memory of all related netmap items.\r
   Removes all nodes of the Recycled doubly linked list and free memory of all related netmap items.\r
-  The number of the <Key, Value> pairs in the netmap is set to be zero.\r
+  The number of the <Key, Value> pairs in the netmap is set to zero.\r
   \r
   If Map is NULL, then ASSERT().\r
   \r
@@ -550,7 +550,7 @@ NetMapInsertTail (
   );\r
 \r
 /**\r
-  Find the key in the netmap and returns the point to the item contains the Key.\r
+  Finds the key in the netmap and returns the point to the item containing the Key.\r
   \r
   Iterate the Used doubly linked list of the netmap to get every item. Compare the key of every \r
   item with the key to search. It returns the point to the item contains the Key if found.\r
@@ -695,9 +695,9 @@ NetMapIterate (
   @param[in]       Controller            The controller which has the service installed.\r
   @param[in]       Image                 The image handle used to open service.\r
   @param[in]       ServiceBindingGuid    The service's Guid.\r
-  @param[in, out]  ChildHandle           The handle to receive the create child.\r
+  @param[in, out]  ChildHandle           The handle to receive the created child.\r
 \r
-  @retval EFI_SUCCESS           The child is successfully created.\r
+  @retval EFI_SUCCESS           The child was successfully created.\r
   @retval Others                Failed to create the child.\r
 \r
 **/\r
@@ -711,7 +711,7 @@ NetLibCreateServiceChild (
   );\r
 \r
 /**\r
-  Destory a child of the service that is identified by ServiceBindingGuid.\r
+  Destroy a child of the service that is identified by ServiceBindingGuid.\r
   \r
   Get the ServiceBinding Protocol first, then use it to destroy a child.\r
   \r
@@ -720,10 +720,10 @@ NetLibCreateServiceChild (
   @param[in]   Controller            The controller which has the service installed.\r
   @param[in]   Image                 The image handle used to open service.\r
   @param[in]   ServiceBindingGuid    The service's Guid.\r
-  @param[in]   ChildHandle           The child to destory.\r
+  @param[in]   ChildHandle           The child to destroy.\r
 \r
-  @retval EFI_SUCCESS           The child is successfully destoried.\r
-  @retval Others                Failed to destory the child.\r
+  @retval EFI_SUCCESS           The child is successfully destroyed.\r
+  @retval Others                Failed to destroy the child.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -742,18 +742,18 @@ NetLibDestroyServiceChild (
 \r
   Get the mac address of the Simple Network protocol from the SnpHandle. Then convert\r
   the mac address into a unicode string. It takes 2 unicode characters to represent \r
-  a 1 byte binary buffer. Plus one unicode character for the null-terminator.\r
+  a 1 byte binary buffer, plus one unicode character for the null terminator.\r
 \r
 \r
-  @param[in]   SnpHandle             The handle where the simple network protocol is\r
-                                     installed on.\r
-  @param[in]   ImageHandle           The image handle used to act as the agent handle to\r
+  @param[in]   SnpHandle             The handle on which the simple network protocol is\r
+                                     installed.\r
+  @param[in]   ImageHandle           The image handle to act as the agent handle to\r
                                      get the simple network protocol.\r
   @param[out]  MacString             The pointer to store the address of the string\r
                                      representation of  the mac address.\r
   \r
-  @retval EFI_SUCCESS           Convert the mac address a unicode string successfully.\r
-  @retval EFI_OUT_OF_RESOURCES  There are not enough memory resource.\r
+  @retval EFI_SUCCESS           Converted the mac address a unicode string successfully.\r
+  @retval EFI_OUT_OF_RESOURCES  There are not enough memory resources.\r
   @retval Others                Failed to open the simple network protocol.\r
 \r
 **/\r
@@ -799,8 +799,8 @@ NetLibCreateIPv4DPathNode (
 /**\r
   Find the UNDI/SNP handle from controller and protocol GUID.\r
   \r
-  For example, IP will open a MNP child to transmit/receive\r
-  packets, when MNP is stopped, IP should also be stopped. IP\r
+  For example, IP will open an MNP child to transmit/receive\r
+  packets. When MNP is stopped, IP should also be stopped. IP\r
   needs to find its own private data which is related the IP's\r
   service binding instance that is install on UNDI/SNP handle.\r
   Now, the controller is either a MNP or ARP child handle. But\r
@@ -926,8 +926,8 @@ typedef struct {
 } NET_VECTOR;\r
 \r
 //\r
-//NET_BLOCK_OP operate on the NET_BLOCK, It specifies\r
-//where the actual fragment begins and where it ends\r
+//NET_BLOCK_OP operates on the NET_BLOCK. It specifies\r
+//where the actual fragment begins and ends\r
 //\r
 typedef struct {\r
   UINT8               *BlockHead;   // Block's head, or the smallest valid Head\r
@@ -940,13 +940,12 @@ typedef struct {
 \r
 //\r
 //NET_BUF is the buffer manage structure used by the\r
-//network stack. Every network packet may be fragmented,\r
-//and contains multiple fragments. The Vector points to\r
-//memory blocks used by the each fragment, and BlockOp\r
+//network stack. Every network packet may be fragmented. The Vector points to\r
+//memory blocks used by each fragment, and BlockOp\r
 //specifies where each fragment begins and ends.\r
 //\r
-//It also contains a opaque area for protocol to store\r
-//per-packet informations. Protocol must be caution not\r
+//It also contains an opaque area for the protocol to store\r
+//per-packet information. Protocol must be careful not\r
 //to overwrite the members after that.\r
 //\r
 typedef struct {\r
@@ -967,7 +966,7 @@ typedef struct {
 \r
 \r
 //\r
-//A queue of NET_BUFs, It is just a thin extension of\r
+//A queue of NET_BUFs. It is a thin extension of\r
 //NET_BUF functions.\r
 //\r
 typedef struct {\r
@@ -1043,8 +1042,8 @@ NetbufAlloc (
  \r
   Decrease the reference count of the net buffer by one. Free the associated net\r
   vector and itself if the reference count of the net buffer is decreased to 0. \r
-  The net vector free operation just decrease the reference count of the net \r
-  vector by one and do the real resource free operation when the reference count\r
+  The net vector free operation decreases the reference count of the net \r
+  vector by one, and performs the resource free operation when the reference count\r
   of the net vector is 0. \r
  \r
   @param[in]  Nbuf                  Pointer to the NET_BUF to be freed.\r
@@ -1060,8 +1059,8 @@ NetbufFree (
   Get the index of NET_BLOCK_OP that contains the byte at Offset in the net \r
   buffer. \r
   \r
-  This can be used to, for example, retrieve the IP header in the packet. It \r
-  also can be used to get the fragment that contains the byte which is used \r
+  For example, this function can be used to retrieve the IP header in the packet. It \r
+  also can be used to get the fragment that contains the byte used \r
   mainly by the library implementation itself. \r
 \r
   @param[in]   Nbuf      Pointer to the net buffer.\r
@@ -1152,7 +1151,7 @@ NetbufGetFragment (
 /**\r
   Reserve some space in the header room of the net buffer.\r
 \r
-  Upon allocation, all the space are in the tail room of the buffer. Call this \r
+  Upon allocation, all the space is in the tail room of the buffer. Call this \r
   function to move some space to the header room. This function is quite limited\r
   in that it can only reserve space from the first block of an empty NET_BUF not \r
   built from the external. But it should be enough for the network stack. \r
@@ -1196,8 +1195,8 @@ NetbufAllocSpace (
   @param[in]      FromHead      The flag to indicate whether trim data from head \r
                                 (TRUE) or tail (FALSE).\r
 \r
-  @return    Length of the actually trimmed data, which is possible to be less \r
-             than Len because the TotalSize of Nbuf is less than Len.\r
+  @return    Length of the actually trimmed data, which may be less \r
+             than Len if the TotalSize of Nbuf is less than Len.\r
 \r
 **/\r
 UINT32\r
@@ -1212,7 +1211,7 @@ NetbufTrim (
   Copy Len bytes of data from the specific offset of the net buffer to the \r
   destination memory.\r
  \r
-  The Len bytes of data may cross the several fragments of the net buffer.\r
+  The Len bytes of data may cross several fragments of the net buffer.\r
  \r
   @param[in]   Nbuf         Pointer to the net buffer.\r
   @param[in]   Offset       The sequence number of the first byte to copy.\r
@@ -1235,17 +1234,17 @@ NetbufCopy (
 /**\r
   Build a NET_BUF from external blocks. \r
    \r
-  A new NET_BUF structure will be created from external blocks. Additional block\r
+  A new NET_BUF structure will be created from external blocks. An additional block\r
   of memory will be allocated to hold reserved HeadSpace bytes of header room\r
-  and existing HeadLen bytes of header but the external blocks are shared by the\r
+  and existing HeadLen bytes of header, but the external blocks are shared by the\r
   net buffer to avoid data copying.\r
 \r
   @param[in]  ExtFragment           Pointer to the data block.\r
   @param[in]  ExtNum                The number of the data blocks.\r
   @param[in]  HeadSpace             The head space to be reserved.\r
-  @param[in]  HeadLen               The length of the protocol header, This function\r
-                                    will pull that number of data into a linear block.\r
-  @param[in]  ExtFree               Pointer to the caller provided free function.\r
+  @param[in]  HeadLen               The length of the protocol header. The function\r
+                                    pulls this amount of data into a linear block.\r
+  @param[in]  ExtFree               Pointer to the caller-provided free function.\r
   @param[in]  Arg                   The argument passed to ExtFree when ExtFree is\r
                                     called.\r
 \r
@@ -1273,7 +1272,7 @@ NetbufFromExt (
   @param[in, out]  ExtFragment           Pointer to the data block.\r
   @param[in, out]  ExtNum                The number of the data blocks.\r
 \r
-  @retval EFI_BUFFER_TOO_SMALL  The number of non-empty block is bigger than \r
+  @retval EFI_BUFFER_TOO_SMALL  The number of non-empty blocks is bigger than \r
                                 ExtNum.\r
   @retval EFI_SUCCESS           Fragment table is built successfully.\r
 \r
@@ -1294,8 +1293,8 @@ NetbufBuildExt (
    \r
   @param[in]   BufList    A List of the net buffer.\r
   @param[in]   HeadSpace  The head space to be reserved.\r
-  @param[in]   HeaderLen  The length of the protocol header, This function\r
-                          will pull that number of data into a linear block.\r
+  @param[in]   HeaderLen  The length of the protocol header. The function\r
+                          pulls this amount of data into a linear block.\r
   @param[in]   ExtFree    Pointer to the caller provided free function.\r
   @param[in]   Arg        The argument passed to ExtFree when ExtFree is called.\r
 \r
@@ -1421,8 +1420,8 @@ NetbufQueCopy (
   );\r
 \r
 /**\r
-  Trim Len bytes of data from the queue header, release any of the net buffer \r
-  whom is trimmed wholely.\r
+  Trim Len bytes of data from the queue header and release any net buffer \r
+  that is trimmed wholely.\r
    \r
   The trimming operation is the same as NetbufTrim but applies to the net buffer\r
   queue instead of the net buffer.\r